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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 a select with an information for each day from the

Author  Topic 

sebastian11c
Posting Yak Master

129 Posts

Posted - 2012-02-20 : 14:50:35
hi there i need to do a select that sum all the records from a day and shows after the end of the day

example
i have this table

idbill service price date (mm/dd/yyyy)
1 wash 55 '01/01/2012'
2 wash 55 '01/01/2012'
3 wash 70 '01/02/2012'
4 wash 65 '01/02/2012'

i want to do a select with this result (but i dont know how)

idbill service price date (mm/dd/yyyy)
1 wash 55 '01/01/2012'
2 wash 55 '01/01/2012'
total 110
3 wash 70 '01/02/2012'
4 wash 65 '01/02/2012'
total 135
and etc

any help will be appreciate

thanks in advanced

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-20 : 14:57:34
quote:
Originally posted by sebastian11c

hi there i need to do a select that sum all the records from a day and shows after the end of the day

example
i have this table

idbill service price date (mm/dd/yyyy)
1 wash 55 '01/01/2012'
2 wash 55 '01/01/2012'
3 wash 70 '01/02/2012'
4 wash 65 '01/02/2012'

i want to do a select with this result (but i dont know how)

idbill service price date (mm/dd/yyyy)
1 wash 55 '01/01/2012'
2 wash 55 '01/01/2012'
total 110
3 wash 70 '01/02/2012'
4 wash 65 '01/02/2012'
total 135
and etc

any help will be appreciate

thanks in advanced




[code]
select idbill, service, price, date
from table

union all

select 0,service,sum(price),date
from table
group by service,date
order by service,date,idbill desc




------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sebastian11c
Posting Yak Master

129 Posts

Posted - 2012-02-20 : 15:16:15
THANKS AGAIN

your answer works


but are there any other way to do? may be more elegant, i need to send a report with this information


many thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-20 : 15:19:07
not any other easier ways in sql

you can very easily generate this format it most reporting tools using report group footers

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sebastian11c
Posting Yak Master

129 Posts

Posted - 2012-02-20 : 15:28:41
many thanks
kind regards
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-20 : 15:57:18
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -