由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 请求SQL语句
相关主题
请教高手,包子谢SQL question...
问个SQL问题- partial outer joinSQL question: update a field
SQL combine two tables into one table and add a new column请教set和select 的区别
SQL copy a table into a new table and add a new column怎样快速得到两个表的交集
新手请教SQL 语法问题- alias 和 join请教大虾问题哈,包子谢哈
error of executing SQL query of string concatenation (转载菜鸟问题,急
一个有关查询的语句问一道SQL的题 (转载)
Question about the err when export tableSQL 查询已经解决.谢谢Modeler,mirthc,cheungche
相关话题的讨论汇总
话题: table2话题: memberid话题: itemid话题: purchaseid话题: select
进入Database版参与讨论
1 (共1页)
r****r
发帖数: 1839
1
Table1:
MemberID
PurchaseID
Table2:
PurchaseID
ItemID
Date
LineNumber
给出Table2中所有行,满足如下条件:
同一个Member在同一天里购买多于一次ItemID=‘手表’
前年我会这个,今年忘记了。多谢。
B*****g
发帖数: 34098
2
http://www.w3schools.com/sql/sql_having.asp

【在 r****r 的大作中提到】
: Table1:
: MemberID
: PurchaseID
: Table2:
: PurchaseID
: ItemID
: Date
: LineNumber
: 给出Table2中所有行,满足如下条件:
: 同一个Member在同一天里购买多于一次ItemID=‘手表’

r****r
发帖数: 1839
3
北京,你帮我写出来吧,比较急,那个网站我经常去,晚上再学习。

【在 B*****g 的大作中提到】
: http://www.w3schools.com/sql/sql_having.asp
r****r
发帖数: 1839
4
我照猫画虎写了一个
Select PurchaseID, ItemID, Date, LineNumber, count(MemberID) from Table1 t1
join Table2 t2 on t1.PurchaseID=t2.PurchaseID where t2.ItemID=‘手表’ group
by MemberID having count(MemberID) > 1
对吗?

【在 r****r 的大作中提到】
: Table1:
: MemberID
: PurchaseID
: Table2:
: PurchaseID
: ItemID
: Date
: LineNumber
: 给出Table2中所有行,满足如下条件:
: 同一个Member在同一天里购买多于一次ItemID=‘手表’

B*****g
发帖数: 34098
5
你要我提供答案,读以下link。
http://www.mitbbs.com/article_t/Database/31150169.html

t1
group

【在 r****r 的大作中提到】
: 我照猫画虎写了一个
: Select PurchaseID, ItemID, Date, LineNumber, count(MemberID) from Table1 t1
: join Table2 t2 on t1.PurchaseID=t2.PurchaseID where t2.ItemID=‘手表’ group
: by MemberID having count(MemberID) > 1
: 对吗?

r****r
发帖数: 1839
6
MS SQL 2008.

【在 B*****g 的大作中提到】
: 你要我提供答案,读以下link。
: http://www.mitbbs.com/article_t/Database/31150169.html
:
: t1
: group

B*****g
发帖数: 34098
7
SELECT *
FROM (SELECT t2.*,
COUNT(*) OVER (PARTITION BY t1.MemberID, t2.Date) NumOfMulti
FROM table1 t1, table2 t2
WHERE t1.PurchaseID = t2.PurchaseID
AND t2.ItemID = '手表')
WHERE NumOfMulti > 1

【在 r****r 的大作中提到】
: MS SQL 2008.
r****r
发帖数: 1839
8
20个包子奉上。

NumOfMulti

【在 B*****g 的大作中提到】
: SELECT *
: FROM (SELECT t2.*,
: COUNT(*) OVER (PARTITION BY t1.MemberID, t2.Date) NumOfMulti
: FROM table1 t1, table2 t2
: WHERE t1.PurchaseID = t2.PurchaseID
: AND t2.ItemID = '手表')
: WHERE NumOfMulti > 1

B*****g
发帖数: 34098
9
http://msdn.microsoft.com/en-us/library/ms189461.aspx
http://msdn.microsoft.com/en-us/library/ms189798.aspx

【在 r****r 的大作中提到】
: 20个包子奉上。
:
: NumOfMulti

1 (共1页)
进入Database版参与讨论
相关主题
SQL 查询已经解决.谢谢Modeler,mirthc,cheungche新手请教SQL 语法问题- alias 和 join
mysql 问题 (转载)error of executing SQL query of string concatenation (转载
how to write this query一个有关查询的语句
请问个join的问题Question about the err when export table
请教高手,包子谢SQL question...
问个SQL问题- partial outer joinSQL question: update a field
SQL combine two tables into one table and add a new column请教set和select 的区别
SQL copy a table into a new table and add a new column怎样快速得到两个表的交集
相关话题的讨论汇总
话题: table2话题: memberid话题: itemid话题: purchaseid话题: select