我想創建一個查詢,它需要在子查詢上進行連接。不過,我還需要能夠通過主查詢的結果來限制子查詢的結果。在查詢(和子查詢)之間共享值
我修改了我以前的問題,以顯示我想運行的完整「概念」查詢。我知道它會充滿各種問題,但我缺乏足夠的經驗(當前)來修改足夠的語法來運行此查詢。下面
實施例:
SELECT
w.timestamp,
c.timestamp
FROM
table1 w
FULL OUTER JOIN
(SELECT
customer_id,
timestamp
FROM
table1 c
HAVING
c.timestamp < w.timestamp
AND
timestamp = MAX(c.timestamp)) c
ON
w.customer_id = c.customer_id
WHERE
payment_type_code='WithdrawPayment'
AND
w.customer_id IN
(SELECT
customer_id,
timestamp
FROM
table1
WHERE
c.timestamp < w.timestamp
AND
timestamp = MAX(c.timestamp)
ORDER BY
c.timestamp DESC
)
HAVING
(SELECT
COUNT(*)
FROM
table1 u
WHERE
u.timestamp > c.timestamp
AND
u.timestamp < w.timestamp) u > 0
;
任何幫助,將不勝感激。
範圍規則。只需將「c.timestamp
jarlh
因此我可以這樣寫:SELECT w.timestamp, c.timestamp FROM表1 W¯¯ FULL OUTER JOIN (SELECT CUSTOMER_ID, 時間戳 FROM表1 ç HAVING 時間戳= MAX(c.timestamp)) c ON w.customer_id
Nic2352
不確定這會對我有用,因爲我試圖加入customer_id,但只有在c.timestamp
Nic2352