Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Maddy_30
Starting Member
2 Posts |
Posted - 2014-05-26 : 05:04:32
|
I have a table with the following data TicketNum(VARCHAR) Amount(DECIMAl)10000000008 13.510000000009 1010000000012 10.7810000000233 0.23I need the count of Ticket numbers having amount less than $30Also the amount should be integers .sample:amount Ticket_Count 10 2 13 1This is the query i have come so far select CAST(Amount as Int) as Amt ,CAST(count(ticketNumber)as INT) as count from tablename where Amount < 50 group by AmountOuput I get is :amount Ticket_Count 10 1 10 1 13 1the ticket count should be 2 for $10 . Please help how can I get that. Maddy |
|
Tusharp86
Starting Member
9 Posts |
Posted - 2014-05-26 : 05:19:51
|
select CAST(Amount as Int) as Amt ,CAST(count(ticketNumber)as INT) as countfrom tic where Amount < 50 group by CAST(Amount as Int) |
|
|
GouravSaxena1987
Starting Member
23 Posts |
Posted - 2014-05-26 : 12:45:55
|
Maddy,Solution given by Tusharp should work!!Regards,Gourav SaxenaData Warehouse CounsultantGouravSaxena1987@gmail.com |
|
|
Maddy_30
Starting Member
2 Posts |
Posted - 2014-05-26 : 22:19:10
|
Hey, Thanks it worked !!!Maddy |
|
|
|
|
|