September 11, 2009 at 1:39 am
hi........
i have table like this.
id product
--------------------
1 cello
2 cello
3 cello
4 cello
5 cello grip
6 cello grip
i need output like this
----------------------
tempid or id product count
------------------------------
1 cello 4
2 cellogrip 2
could u please help me ........for that
Thanks
Dastagiri.D
September 11, 2009 at 2:57 am
You question is not very clear to me, but I think this should do the trick:
SELECT MIN(id), Product, COUNT(*)
FROM MyTable
GROUP BY Product
-- Gianluca Sartori
September 11, 2009 at 3:41 am
yes this is correct answer for me thanks..
Thanks
Dastagiri.D
September 11, 2009 at 3:46 am
I believe this would do (not near an SQL Server right now so can't test)...
SELECT ROW_NUMBER() OVER (ORDER BY Product) AS TempID,
Product, COUNT(*)
FROM MyTable
GROUP BY Product
If that doesn't get it because of a GROUP BY error, post back.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply