Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

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
[400 byte] By [sheryl kemp] at [2007-11-9 21:11:28]
# 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
Jason Rein at 2007-11-11 23:50:44 >