易截截图软件、单文件、免安装、纯绿色、仅160KB

求一条SQL语句。

ID  餐别    时间
1  中餐 2009-10-25
2  中餐 2009-10-26
3  晚餐 2009-10-26
4  早餐 2009-10-27

结果
1  中餐 2009-10-25
3  晚餐 2009-10-26
4  早餐 2009-10-27

日期中有重复的。。我想一直得到最新的。。帮忙谢谢了
虽然对大家有些简单。但是有没有经典的算法呀。
这种问题在报表中总是出现。。

UP

SQL code:

select * from tb a where not exists(select 1 from tb where a.餐别=餐别 and a.时间<时间)


SQL code:

--> 测试数据: @T1
declare @T1 table (ID int,餐别 varchar(4),时间 datetime)
insert into @T1
select 1,'中餐','2009-10-25' union all
select 2,'中餐','2009-10-26' union all
select 3,'晚餐','2009-10-26' union all
select 4,'早餐','2009-10-27'

select * from @t1 a where not exists(select 1 from @t1 where a.餐别=餐别 and a.时间> 时间)

ID 餐别 时间
----------- ---- ------------------------------------------------------
1 中餐 2009-10-25 00:00:00.000
3 晚餐 2009-10-26 00:00:00.000
4 早餐 2009-10-27 00:00:00.000

(所影响的行数为 3 行)
3楼有点错误

SQL code
{{-


相关问答:

关于group by的sql语句?

  with adod_dict do
    begin
    close;
    commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......

sql语句获取记录数

StrSQL="Select * from "&DataTable&" Where ID In("& ID &") and Shop_ID="&Shop_ID&Taxis


如何获取他的记录数?
@@ROWCOUNT

Select count(* ......

sql查询问题

http://wenda.tianya.cn/wenda/thread?tid=008e40988f9b74c0
我的问题写在这里了拜托大家看看,上午csnd升级不能用就在天涯上写了。
这里面写了发表不了总说有非法词或词组很郁闷,谢谢大家 
FULL JOI ......

一个sql语句。

我想查出
month
1
2
3
4
5
6
7
8
9
10
11
12
这样的数据,如何实现啊。。。

SQL code:

select top 12 month=identity(int,1,1) into #t from sysobjects
selec ......

SQL 关于多条update

例如有2个表 一个是员工信息表 表里有名字 工资等字段 一个是公司财务表有 每月总支出等字段

现在要给一个员工涨工资 500RMB  就要写2条 UPDATE语句(假设只有两张表。实际肯定要更多)

问:如何 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号