SQL查询相同的列数?

时间:2013-09-20 08:02:40

标签: sql

我试图弄清楚如何编写一个计算多列值的查询

Uniform  size
-------   ---
Shirts     34
Shirts     36
Trouser    30
Shirts     34
Trouser    30
Trouser    32
Shoe        8
Shirts     34
Shoe        9
Saree       6

我们可以这样做吗

  Uniform  Size  cont
  -------  ----  -----
  Shirts   34     3
  Shirts   36     1
  Trouser  30     2
  Trouer   32     1
  shoe     8      1
  shoe     6      1
  saree    6      1

请帮帮我

1 个答案:

答案 0 :(得分:2)

select uniform, size, count(uniform) from thetable group by uniform, size