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# code:
我自 ......
sql server 2005 触发器 执行sp_executesql 的问题
db1,db2是一个服务器 server 的2个数据库
db1的table1 建立一个after update触发器 ,当 update table1 后建立一个复制表到 db2的tabl ......
各位大侠,我有一个xml文件
XML code:
<?xml version="1.0" encoding="GB2312"?>
<FileId fileid="86">
<ResultSet>
<row id="0">
......
请帮忙看看怎么优化一下,该表数据约为66万,运行时间要19秒,SQL如下:
select DATEPART (hh ,Date_time ) as Hours ,
sum(Counts)*100.0/(Select sum(Counts) as total
&nbs ......