求助排序问题-有难度

dxb321 2005-01-10 09:03:11
设我有一字段,其只包含数字{0,1,2,3},我想查询结果按这样方式排序 1,2,3,0.怎样写查询语句.
例:
name flag
a 0
a 1
c 2
b 3
查询结果为:
name flag
a 1
c 2
b 3
a 0
...全文
100 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yesyesyes 2005-01-11
  • 打赏
  • 举报
回复
select * from tbl order by case when flag=0 then flag*100 else flag end
mathematician 2005-01-11
  • 打赏
  • 举报
回复
刚才那句有点问题,改正如下:
select name,flag from tab_name where flag<>0
union all
select name,flag from tab_name where flag=0;
mathematician 2005-01-11
  • 打赏
  • 举报
回复
用union 就可以了,我用mysql调试通过,你根据access语法自己修改一下吧!
select name,flag from tab_name where flag<>0 order by flag
union all
select name,flag from tab_name where flag=0;
dxb321 2005-01-11
  • 打赏
  • 举报
回复
up
trampwind 2005-01-11
  • 打赏
  • 举报
回复
select * from tabname where flag<>0 order by flag union all select * from tabname where flag=0;

7,713

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
社区管理员
  • Access
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧