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
非常感谢两位高手指点。。
谢谢谢。。。。。。。。。。。。。
相关问答:
本人c#新手 可是要求要用c# ,sql2000开发c/s的工作流,一头雾水,请大家帮忙帮忙,给点思路,说的约具体越好,我也好往那个方面去学习
http://www.hxzi.com/view/61402.html
B/S版的,基本思想应该差不多的。。 ......
....接到一个小程序..工作原来大概是这样的...前台是WEB服务器.架构就是ASP+SQL..前台由ASP向SQL添加服务类别(表单).然后又后台程序读取表单..要实时读取..然后显示在服务器上面..从理论上面能行通不?如果可以..后台 ......
各位大侠,我有一个xml文件
XML code:
<?xml version="1.0" encoding="GB2312"?>
<FileId fileid="86">
<ResultSet>
<row id="0">
......
怎么把下面的改成sql server的方法?
to_char(img_comm_metadata.scene_centre_time,'yyyy-mm-dd hh24:mm:ss')>='1990-10-13 09:41:20'
SQL code:
datediff(ss,'1990-10-13 09:41:20',img_ ......
'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' ......