avatar
穿越利器,蜀山6G# Joke - 肚皮舞运动
o*y
1
我们有 two tables purchase(pur_id, cust_id, prod_id, p_price, p_time) and
product(prod_id, seller_id, s_time, s_price), where the primary key of
purchase is pur_id, and the primary key of product is prod_id, seller_id,
time.
To find all sellers who sell the product in purchase 001, list the seller id
, his most recent selling time for the product, and the price at this time.
Assume that there is only one product in each purchase.
SELECT seller_id, MAX(s_time) as recent_time, s_price
FROM product pd
avatar
m*d
2
avatar
t*d
3
select seller_id, s_price from product p1 ,
( select seller_id, max(s_time) recent_time from
product pd, purchase pc
WHERE pd.prod_id = pc.prod_id
AND pc.pur_id = '001'
GROUP BY seller_id) t where p1.seller_id = t.seller_id and
p1.s_time = t.recent_time;
avatar
s*i
4
好玩
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。