以下の構文がエラーとなってしまうのですが、どこか間違っているかご教示頂きたく。
よろしくお願いします。
SELECT DISTINCT
F_purchase.name AS name,
F_purchase.product AS f_product,
S_purchase.product AS s_product,
S_purchase.createdate - F_purchase.createdate AS date
FROM (SELECT A.name,
A.product,
A.createdate
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY name
ORDER BY createdate ASC) AS RowNo,
name,
product,
createdate
FROM test_purchase) AS A
WHERE RowNo = 1) F_purchase INNER JOIN
(SELECT B.name,
B.product,
B.createdate
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY name
ORDER BY createdate ASC) AS RowNo,
name,
product,
createdate
FROM test_purchase) AS B
WHERE RowNo = 2) S_purchase ON F_purchase.name = S_purchase.name
あなたの回答
tips
プレビュー