哪位来帮忙写个sql语句,谢了!!

[复制链接]
查看11 | 回复2 | 2005-3-15 21:35:00 | 显示全部楼层 |阅读模式
表:
id(int)
type(varchar) name(varchar) time(DateTime)
1

a
2004-12-23
2

b
2004-12-30
3

c
2005-01-12
4

d
2005-01-10
5

e
2005-01-09
现在要按:
1.优,良,中
2.时间 排序
也就是结果为:
2

b
2004-12-30
1

a
2004-12-23
4

d
2005-01-10
3

c
2005-01-12
5

e
2005-01-09

请高手帮忙,谢谢
回复

使用道具 举报

千问 | 2005-3-15 21:35:00 | 显示全部楼层
如果只有‘优良中’应该效率还可以,但如果太多项而且表比较大的话效率就低了。
select *
from table1
where type='优'
UNION all
select *
from table1
where type='良'
UNION ALL
select *
from table1
where type='中'
order by 4
回复

使用道具 举报

千问 | 2005-3-15 21:35:00 | 显示全部楼层
select * from table order by type,time
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行