注册 登录
编程论坛 SQL Server论坛

请教一个问题:关于sql查询的,笔试试题,哪位高人告诉下

qwaszhoudh 发布于 2007-04-05 22:56, 925 次点击
二、
RenId 性别 薪水
31 男 3000
23 女 1200
32 男 2500
22 男 1600
13 Null 3200

怎么得到这样的输出结果?

性别 人数
男 3
女 1

三、有一个表是这样的
Sname
class
score

找出每个班级的前三名并输出
1 回复
#2
棉花糖ONE2007-04-05 23:25
select 性别,count(性别) from table where 性别 is not null group by 性别
select * from table t1 where score in (select top 3 score from table where class=t1.class)
1