首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Access >

关于排列解决方案

2012-02-07 
关于排列数据表结构mcjgsj1102007-03-011202007-03-02252007-03-012102007-03-09想要得到结果mcjgsj120200

关于排列
数据表结构
    mc       jg       sj
      1       10       2007-03-01
      1       20       2007-03-02
      2       5         2007-03-01
      2       10       2007-03-09
想要得到结果
    mc       jg       sj
    1         20       2007-03-02
    2         10       2007-03-09

[解决办法]
--如果mc相同,取jg最大的记录

SELECT *
FROM 表名 as T
where not exists (select * from 表名 where mc=T.mc and jg> t.jg)

--如果mc相同,取sj最大的记录

SELECT *
FROM 表名 as T
where not exists (select * from 表名 where mc=T.mc and sj> t.sj)

热点排行