日期:2014-05-17 浏览次数:21075 次
SELECT COUNT (1) FROM big_house WHERE lsh_xm = 100000303 AND ywlx IN( 0,2,3,4) GROUP BY ywlx ORDER BY ywlx
------解决方案--------------------
SELECT COUNT (1)
FROM big_house
WHERE lsh_xm = 100000303 and ywlx in(0,2,3,4)
------解决方案--------------------
SELECT SUM(CASE WHEN ywlx=0 THEN 1 ELSE 0 ) 0, SUM(CASE WHEN ywlx=2 THEN 1 ELSE 0 ) 2, SUM(CASE WHEN ywlx=3 THEN 1 ELSE 0 ) 3, SUM(CASE WHEN ywlx=4 THEN 1 ELSE 0 ) 4 FROM big_house WHERE lsh_xm = 100000303 AND ywlx IN( 0,2,3,4)
------解决方案--------------------
SELECT SUM(CASE WHEN ywlx=0 THEN 1 ELSE 0 ) 0,
SUM(CASE WHEN ywlx=2 THEN 1 ELSE 0 ) 2,
SUM(CASE WHEN ywlx=3 THEN 1 ELSE 0 ) 3,
SUM(CASE WHEN ywlx=4 THEN 1 ELSE 0 ) 4
FROM big_house
WHERE lsh_xm = 100000303
AND ywlx IN( 0,2,3,4)
这个才是正确的
------解决方案--------------------
SELECT SUM(CASE WHEN ywlx=0 THEN 1 ELSE 0 ) 0,
SUM(CASE WHEN ywlx=2 THEN 1 ELSE 0 ) 2,
SUM(CASE WHEN ywlx=3 THEN 1 ELSE 0 ) 3,
SUM(CASE WHEN ywlx=4 THEN 1 ELSE 0 ) 4
FROM big_house
WHERE lsh_xm = 100000303
AND ywlx IN( 0,2,3,4)