d*******n 发帖数: 109 | 1 this is a single table query,
table looks like this:
column1 column2 column3 column4
1 0 1 0
0 1 1 1
1 0 0 0
1 1 1 1
...
four columns, each can be 1 or 0,
write one SQL query to get output looks like
TotalRow Count1 Count23 Count4
total row is the total row of table
count1 is the count of all row which column1 = 1 and the rest 3 columns are
0
count23 is the count of all row which column2 = 1 and column = 1 and column1
= 0 and column4 = 0
count4 is the count of all row which column4 = 1 and the rest columns are 0
so the above result should be like:
TotalRow Count1 Count23 Count4
4 0 0 0
如果上面的能用一个query解决,
能不能用同样的table,让输出是竖的,比如
TotalRow 4
Count1 0
Count23 0
Count4 0
谢谢 | B*****g 发帖数: 34098 | 2 http://stackoverflow.com/questions/12628585/how-to-do-a-sum-ins
【在 d*******n 的大作中提到】 : this is a single table query, : table looks like this: : column1 column2 column3 column4 : 1 0 1 0 : 0 1 1 1 : 1 0 0 0 : 1 1 1 1 : ... : four columns, each can be 1 or 0, : write one SQL query to get output looks like
|
|