|
Posted by Tom Moreau on 12/06/05 17:23
Try:
select
o.*
from
Orders
join
(
select
ProductID
, OrderDate
from
Orders
group by
ProductID
, OrderDate
having
count (*) > 1
) x on x.ProductID = o.ProductID
and x.OrderID = o.OrderID
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@cips.ca
www.pinpub.com
"Bruno Panetta" <bpanetta@gmail.com> wrote in message
news:1133881905.481272.320490@g49g2000cwa.googlegroups.com...
> Suppose I have a table Orders with the following fields:
>
> OrderID ProductID OrderDate
>
> I would like a SELECT query to return those rows with multiple values
> for both ProductID and OrderDate. For example suppose Orders contains
> the following data
>
> OrderID ProductID OrderDate
> 1 11 12-mar-2005
> 2 13 13-mar-2005
> 3 13 13-mar-2005
> 4 13 13-mar-2005
> 5 13 14-mar-2005
> 5 14 14-mar-2005
> 6 15 15-mar-2005
> 7 15 15-mar-2005
>
> then the query would return the rows corresponding to OrderID's 2, 3,
> 4, 6, 7.
> How can this be done?
> Thanks.
>
Navigation:
[Reply to this message]
|