Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT p.[name]
- FROM products p
- WHERE p.product_id in (SELECT s.product_id
- FROM productsales s
- WHERE s.[date] between @dateStart and @dateEnd
- GROUP BY s.product_id
- HAVING Sum(s.quantity) > @X )
- HAVING (Sum(s.quantity*s.price)) > @X
- SELECT p.name from products p
- WHERE p.product_id IN
- (SELECT product_id from
- (SELECT product_id, (quantity * price) as total
- FROM productsales WHERE date between @dateStart and @dateEnd) as s
- GROUP by s.product_id
- HAVING sum(total) > @x)
Add Comment
Please, Sign In to add comment