2010-01-11 43 views
0

我有一个表的结果,其中有他以下的列:正确的SQL结构

ID TestCase Platform 
1 P1.1.1 Win1 
2 P2  Win1 
3 P3  Win3 
4 P1.1.1 Win3 

我有平台的只有4 Win1时,WIN2,WIN3,WIN4 的特定类别的测试用例将重复为每个平台。现在

,我很困惑的是:

我需要列出所有不同的TestCases,他们和

i.e  
Platform TestCases 
Win1  P1.1.1 
Win1  P2 
Win3  P1.1.1 
Win3  P3 

Win1_Count = 2 
Win3_count = 3 

计数属于每个平台的任何人都可以请给我如何做任何想法这个?

谢谢。

+0

我假设Win3_Count在你给出的例子中应该是2? – 2010-01-11 10:38:37

+0

是的遗憾的错别字 – JPro 2010-01-11 10:43:50

回答

3
select distinct(Platform,TestCases) from tab order by Platform; 

select Platform,count(*) as count from tab group by Platform order by Platform;