I'm trying to adjust a query but I am very new to using SQL and just found this forum. I would appreciate any help. This will make me much more efficient at my job.
Here is a mock up:
SELECT item_id
FROM item_changes
WHERE customer = 'ABC'
AND item_timestamp >= '2006-01-08'
AND item_timestamp < '2006-01-14'
AND item_attribute IN ('attribute1','attribute2','attribute3')
ORDER BY item_attribute
This returns 50 of attribute 1, 30 of attribute 2 and 15 of attribute 3. I want to limit each of them to 20.
Basically I'm after a sampling of each of those attributes without have to run 3 separate queries and copying and pasting no more than 20 of each.
Is there a way to accomplish this?
Thank you!
--Laureen
Here is a mock up:
SELECT item_id
FROM item_changes
WHERE customer = 'ABC'
AND item_timestamp >= '2006-01-08'
AND item_timestamp < '2006-01-14'
AND item_attribute IN ('attribute1','attribute2','attribute3')
ORDER BY item_attribute
This returns 50 of attribute 1, 30 of attribute 2 and 15 of attribute 3. I want to limit each of them to 20.
Basically I'm after a sampling of each of those attributes without have to run 3 separate queries and copying and pasting no more than 20 of each.
Is there a way to accomplish this?
Thank you!
--Laureen