count, having
Hi, I have a table where I need to extract fields with multiple values.
example: In my table I have multiple Customerid's with multiple orderid's
I need to see customerid's with the same orderid appearing 4 times or more.
(Customerid's having a count of the same orderid more than 4 times.)
I hope this makes sense, kinda hard to explain.
Thanks
# 1 Re: count, having
"sheryl kemp" <sheryl.kemp@wachoiva.com> wrote:
>
>
>Hi, I have a table where I need to extract fields with multiple values.
>example: In my table I have multiple Customerid's with multiple orderid's
>
>I need to see customerid's with the same orderid appearing 4 times or more.
>
>(Customerid's having a count of the same orderid more than 4 times.)
>
>I hope this makes sense, kinda hard to explain.
>Thanks
Try this:
Select
CustomerID,
Count(OrderID)
From
Table1
Group By
CustomerID
Having Count(OrderID) > 4