SQL query result Merging

Source: Internet
Author: User
-10 ~ Number of positive integers between 10

I use

Declare @ A int
Set @ A =-10
If (@ a between-10 and 10)
Begin
While (@ A <= 10)
Begin
Select @ A, case when @ a> 0 then 1
Else 0
End as 'y'
Set @ A = @ A + 1
End
End

The following results are displayed:
Y
----------------------
-10 0

(One row is affected)

Y
----------------------
-9 0

(One row is affected)

Y
----------------------
-8 0

(One row is affected)

Y
----------------------
-7 0

(One row is affected)

Y
----------------------
-6 0

(One row is affected)

Y
----------------------
-5 0

(One row is affected)

Y
----------------------
-4 0

(One row is affected)

Y
----------------------
-3 0

(One row is affected)

Y
----------------------
-2 0

(One row is affected)

Y
----------------------
-1 0

(One row is affected)

Y
----------------------
0 0

(One row is affected)

Y
----------------------
1 1

(One row is affected)

Y
----------------------
2 1

(One row is affected)

Y
----------------------
3 1

(One row is affected)

Y
----------------------
4 1

(One row is affected)

Y
----------------------
5 1

(One row is affected)

Y
----------------------
6 1

(One row is affected)

Y
----------------------
7 1

(One row is affected)

Y
----------------------
8 1

(One row is affected)

Y
----------------------
9 1

(One row is affected)

Y
----------------------
10 1

(One row is affected)

The results are separated and sum operations are not allowed. How can I merge the results with Union all?

There is

@ Value % 2 = 0? "Even": "odd"

How to query
When I add select to the front, a syntax error is prompted near '=.
Thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.