怎样取出如下数据

NMGYUE 2008-03-14 01:40:56
数据库表结构:
id sessionid username password starttime endtime indexNO
1 20080314001 helo 123 2008-03-14 09:32:32 2008-03-14 09:35:31 1
2 20080314001 helo 123 2008-03-14 09:32:32 2008-03-14 09:35:31 2
3 20080314002 dawei 123 2008-03-14 10:33:34 2008-03-14 10:34:20 1
4 20080314003 nik 123 2008-03-14 11:05:53 2008-03-14 11:12:52 1
5 20080314004 shure 123 2008-03-14 17:01:26 2008-03-14 17:01:48 1
6 20080314004 mky 123 2008-03-14 17:01:26 2008-03-14 17:01:48 2

写个Sql语句,按sessionid分组,显示记录,显示格式如下:
20080314001
helo 123 2008-03-14 09:32:32 2008-03-14 09:35:31 1
helo 123 2008-03-14 09:32:32 2008-03-14 09:35:31 2
20080314002
dawei 123 2008-03-14 10:33:34 2008-03-14 10:34:20 1
20080314003
nik 123 2008-03-14 11:05:53 2008-03-14 11:12:52 1
20080314004
shure 123 2008-03-14 17:01:26 2008-03-14 17:01:48 1
mky 123 2008-03-14 17:01:26 2008-03-14 17:01:48 2

...全文
50 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
-狙击手- 2008-03-14
  • 打赏
  • 举报
回复
select seessionid,username,password,stattime,endtime,indexno
from ta
group by seessionid,username,password,stattime,endtime,indexno with rollup
having not (grouping(username)=1 and grouping(password)=1 and grouping(stattime)=1 and grouping(endtime)=1 and grouping(indexno)=0 and grouping(seessionid)=0)

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧