Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请教各位大大。小弟先谢了(SQL 問題)
hotfire00





发贴: 7
积分: 0
于 2006-10-20 11:22 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
表 A 如下
id type count_Number count_Date
1 A 10 2005-02-01
2 B 8 2005-02-01
3 C 5 2005-02-01
4 B 4 2005-02-01
5 C 5 2005-02-01
6 A 11 2005-02-02
7 B 9 2005-02-02
8 C 8 2005-02-02
9 A 15 2005-02-02
10 C 6 2005-02-02
11 A 7 2005-02-03
12 B 11 2005-02-03
13 C 12 2005-02-03

用一条语句生成
日期 类型A 类型B 类型C
2005-02-01 10 12 10
2005-02-02 26 9 14
2005-02-03 7 11 12


{ 请使用准确的文字描述作为标题 }


why edited on 2006-10-23 19:23

作者 Re:请教各位大大。小弟先谢了(SQL 問題) [Re:hotfire00]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-10-23 19:30 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
assume you only want to list dates with type A...
assume unique (does not repeat) count_Date for each type A
assume M$ SQL syntax
then you may try something like
select
AA.countDate as "日期",
AA.count_Number as "类型A",
BB.count_Number as "类型B",
CC.count_Number as "类型C"
from A AA
left outer join A BB on AA.countDate = BB.countDate
left outer join A CC on AA.countDate = CC.countDate



作者 Re:请教各位大大。小弟先谢了(SQL 問題) [Re:hotfire00]
hotfire00





发贴: 7
积分: 0
于 2006-10-24 18:32 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
太感谢了。。。下次一定注意标题



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923