Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 436b21b

Browse files
committed
백제완: [SQL] Product Price at a Given Date_241205
1 parent 674d66e commit 436b21b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
WITH CTE AS (
2+
SELECT
3+
product_id
4+
, new_price
5+
FROM
6+
products
7+
WHERE
8+
(product_id, change_date) IN
9+
(
10+
SELECT
11+
product_id
12+
, MAX(change_date)
13+
FROM
14+
Products
15+
WHERE
16+
change_date <= '2019年08月16日'
17+
GROUP BY
18+
product_id
19+
)
20+
)
21+
22+
SELECT
23+
DISTINCT(A.product_id)
24+
, IFNULL(B.new_price, 10) `price`
25+
FROM
26+
products A
27+
LEFT JOIN CTE B
28+
ON A.product_id = B.product_id

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /