MAN AHL interview
This commit is contained in:
23
puzzles/interviews/man_AHL/sql_query.txt
Normal file
23
puzzles/interviews/man_AHL/sql_query.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
I can imagine that the query should be something like this. But my SQL is not very good.
|
||||
|
||||
SELECT
|
||||
p.product_id as product_id,
|
||||
p.name as name,
|
||||
o.quantity as quantity
|
||||
FROM
|
||||
product p
|
||||
JOIN (
|
||||
SELECT
|
||||
product_id,
|
||||
SUM(quantity) as quantity
|
||||
FROM
|
||||
order
|
||||
WHERE
|
||||
dispatch_date > DATEADD(year, -1, GETDATE())
|
||||
GROUP BY
|
||||
product_id
|
||||
) o ON o.product_id = p.product_id
|
||||
WHERE
|
||||
p.available_from < DATEADD(month, -1, GETDATE())
|
||||
AND o.quantity < 10
|
||||
|
||||
Reference in New Issue
Block a user