SELECT TicketID, count(*) as cnt, ticketcost
FROM [ticket]
GROUP BY TicketID, ticketcost
WITH ROLLUP
ORDER BY TicketID, ticketcost
Delete the 'rollup' line if you don't want the summary of each ticketID.
> Hello, I need a little help with SQL statment.. I have a table
called "ticket"
> and inside this table I have a column called "TicketID" and "ticketcost"
>
> Now, any TicketID could have many differnt prices.. say TicketID 1 could
have 4
> differnt price, TicketID 2 could have 5 diffent prices and etc....
>
> how do I write a SQL stament which shows how many different prices are
there for
> each TicketID?
>
> Examp
> TicketID TicketCost
> 1 $10
> 2 $9
> 1 $15
> 2 $8
> 1 $10
> 2 $7
> 1 $15
>
> so the sql statemnt should return in this example TiketID1 has two
$10, two
> $15, Ticekt ID2 has one $9, one $8, one $7
>
> do I group by "TicketCost" first and then do a Count(TiketID) or?????
>
> thanks...
>
>
>