Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do a Select statement to get this.. 1

Status
Not open for further replies.

jonasggg

Technical User
Sep 30, 2003
12
UY
Hello..
How can I use a select statement to get this result:

(for example for month August)

day - ticket number - Total Amount
1 - 1 (to) 30 - 329.50
2 - 31 (to) 52 - 409.50
3 - 53 (to) 64 - 59.50
4 - 65 (to) 75 - 829.50

etc till day 31

all in one row per day.
thanks..
 
select day(datecolumn) as day,
cast(min(ticketno) as varchar(5)) + ' (to) ' +
cast(max(ticketno) as varchar(5)) as ticketnumber, sum(Amount) as TotalAmount
from Table
where month(datecolumn) = 8 /*for august*/
group by day(datecolumn)
order by day(datecolumn)

-Manjari
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top