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

SQL 语句。。 请教高手

先来一个错误语句。。
select * from [aa] where a1 in (select max(a2),a1 from [aa]  group by a1 )


我大体意思,
读取一个统计系统中 不重复的 IP 按照 最后时间排序,并显示出所有字段。。


高手请帮帮忙,,要求一行语句完成。。
SQL code:
select *
from [aa] t
where not exists(select 1 from [aa] where a1=t.a1 and a2>t.a2)


SQL code:
select * from [aa] a where a2 = (select max(a2) from [aa] where a1=a.a1 )


三楼正解。。。

下面语句调试通过:

select * from [aa] where a2 in (select max(a2) from [aa] group by a1)

查询出 不重复的a1 按照 a2 最大值自由 ASC 或 DESC

非常感谢两位高手指点。。

谢谢谢。。。。。。。。。。。。。




相关问答:

问题:通过sql 枚举sqlserver 上建立的链接服务器列表

问题是这样的,
我的本地sqlserver 2000 服务器上,建立了多个远程链接服务器,
请问,我如何通过 sql语句,或者其他的方法枚举 这些链接服务器呢?(通过企业管理器我是知道的,
我要的是能通过编程枚举到 ......

xml导入sql数据库,急

各位大侠,我有一个xml文件
XML code:

<?xml version="1.0" encoding="GB2312"?>
<FileId fileid="86">
<ResultSet>
<row id="0">
......

delphi中excel导入sql server的问题。

'Select * into mytable from OpenDataSource(''Microsoft.JET.OLEDB.4.0'',''Data Source=f:\test.xls;Mode=Read;Extended Properties=Excel 5.0;Persist Security Info=False' ......

这个SQL该如何写

写SQL语句:
表1:CLASS
含有两个字段:ID,CLASSNAME,表结构如下:
ID CLASSNAME
1    A
2    B
3    C
4    D
表2:STUDENT
含有如下字段:S ......

求一SQL语句。谢谢

id    name    sfz

1    aa    410654198001204562
2    bb    410654198120461287
4    cc    41065419850 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号