0% found this document useful (0 votes)
71 views1 page

Select Sum (A) From (Select 1 A From Dual Union All Select - 1 A From Dual Where 2 &N)

This SQL query selects the sum of column a from a subquery that returns 1 in the first row and conditionally returns -1 in the second row if a number is less than a variable. The result would be 0 if the variable is less than 2, and 1 otherwise.

Uploaded by

Deepak Khosla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views1 page

Select Sum (A) From (Select 1 A From Dual Union All Select - 1 A From Dual Where 2 &N)

This SQL query selects the sum of column a from a subquery that returns 1 in the first row and conditionally returns -1 in the second row if a number is less than a variable. The result would be 0 if the variable is less than 2, and 1 otherwise.

Uploaded by

Deepak Khosla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

select sum(a) from

(
select 1 a from dual
union all
select - 1 a from dual
where 2 < &n
)

You might also like