Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kiki_1410
Starting Member
1 Post |
Posted - 2007-09-10 : 03:08:26
|
| Hi,I am new at SQL hopefully this would be a rather easy question for you guys to help me out with.I have a table called PRODUCT with the following fields:a. Product Nameb. Product Dept.c. Purchase Date.I would like to run a query to obtain all rows that has more than one purchases on any particular day.Any replies would be great. |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-10 : 03:45:53
|
| SELECT [Product Name], [Purchase Date]FROM PRODUCTGROUP BY [Product Name], [Purchase Date]HAVING COUNT(*) > 1ORDER BY [Product Name]If [Purchase Date] include BOTH the Date AND Time then you will need to replace [Purchase Date] with:DATEADD(Day, 0, DATEDIFF(Day, 0, [Purchase Date]))(which will efficiently remove the Time part)Kristen |
 |
|
|
|
|
|