查询一个数字在各列中出现的次数
NumRed1Red2Red3Red4Red5Red6
20030024919202126
20030031710232832
2003004467101325
20030054615173031
20030061310212627
是双色球的期号和红色球出现情况
如何查询各个数字出现的次数(在各列中出现的总和)
对于篮球就一列,本人用的是Select Distinct Blue,Count(*) From History Group By Blue
多列怎么办啊,各位高手
[解决办法]
select red,Count(1) as Total
from (
select Red1 as Red from tabRed union all
select Red2 from tabRed union all
select Red3 from tabRed union all
select Red4 from tabRed union all
select Red5 from tabRed union all
select Red6 from tabRed )a
group by Red
[解决办法]
select red1 as red into #tab from History
select red2 into #tab from History
....
....
select red6 into #tab from History
Select Distinct red,Count(*) From History Group By red
drop #tab