![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I don't think this is really the right place to post this question but I couldn't find any sql groups... Say there are 3 columns: idx (key) product (varchar) mandate (datetime) I want to run a query for all products that were sold on more than one day. For example we may not make a product more than one day and some we might make for 3 days although a product may have been made more then 1 time in a day. Here's a sample: 1 widgetA 1/1/2007 2 widgetB 1/1/2007 3 widgetA 1/1/2007 4 widgetC 1/2/2007 5 widgetD 1/3/2007 6 widgetD 1/3/2007 7 widgetB 1/5/2007 8 widgetD 1/6/2007 So I would want the query to return widgetB and widgetD because they were both made on more then 1 day. -Joe |
#3
| |||
| |||
|
|
Joe wrote: I don't think this is really the right place to post this question but I couldn't find any sql groups... Say there are 3 columns: idx (key) product (varchar) mandate (datetime) I want to run a query for all products that were sold on more than one day. For example we may not make a product more than one day and some we might make for 3 days although a product may have been made more then 1 time in a day. Here's a sample: 1 widgetA 1/1/2007 2 widgetB 1/1/2007 3 widgetA 1/1/2007 4 widgetC 1/2/2007 5 widgetD 1/3/2007 6 widgetD 1/3/2007 7 widgetB 1/5/2007 8 widgetD 1/6/2007 So I would want the query to return widgetB and widgetD because they were both made on more then 1 day. -Joe SELECT COUNT (dat.idx) as idx , dat.mandate , MAX(dat.product) as product FROM dbo.my_data dat GROUP BY dat.mandate HAVING COUNT (dat.idx) > 1 HTH, Petar Atanasov http://a-wake.net |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |