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.
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 ratings0% 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.