CREATE TABLE SIGNS(ID INT)
GO
INSERT INTO SIGNS VALUES(-1),(-2),(-3),(2),(3)
SELECT * FROM SIGNS
METHOD 1:
SELECT SIGN(ID) AS NA_PO,COUNT(SIGN(ID)) AS COUNT_NE_PO FROM signs GROUP BY SIGN(ID)METHOD 2:
SELECT NEGTIVE=COUNT(CASE WHEN ID<0 THEN 1 ELSE NULL END),
POSTIVE=COUNT(CASE WHEN ID>0 THEN 1 ELSE NULL END)
FROM SIGNS
No comments:
Post a Comment