穿越利器,蜀山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
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