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
非常感谢两位高手指点。。
谢谢谢。。。。。。。。。。。。。
相关问答:
....接到一个小程序..工作原来大概是这样的...前台是WEB服务器.架构就是ASP+SQL..前台由ASP向SQL添加服务类别(表单).然后又后台程序读取表单..要实时读取..然后显示在服务器上面..从理论上面能行通不?如果可以..后台 ......
users表
name companyId companyName
company表
companyId companyName
1 a公司
2 b公司
......
小弟是个新手 现在有个问题一直不能解决
例如
procedure produce_proc
@p001 nvarchar(8000),
@p002 nvarchar(8000),
@p003 nvarchar(8000),
& ......
字段aa,共有178个数据,显示时是一列直排下来的,我想让这178个数据,每列只显示5个,多列显示完,如何实现?
加一个IDENTITYT列,按ID%5来分
引用
加一个IDENTITYT列,按ID%5来分
ID-1/5来分
SQL co ......
with adod_dict do
begin
close;
commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......