﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / group wise sum query / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 10:45:35 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: group wise sum query</title><link>http://www.sqlservercentral.com/Forums/Topic1412764-392-1.aspx</link><description>where do you want to display...Report, or UI or Query result? </description><pubDate>Tue, 29 Jan 2013 01:12:21 GMT</pubDate><dc:creator>Suresh-209155</dc:creator></item><item><title>RE: group wise sum query</title><link>http://www.sqlservercentral.com/Forums/Topic1412764-392-1.aspx</link><description>Is something like this close enough for you?[code="sql"]DECLARE @Expenses TABLE    ([S.no] INT    ,[Travel Expense] MONEY    ,[Stay Expense] MONEY    ,[Mis Expens] MONEY    ,[Date] DATE    ,[Employee] VARCHAR(10))INSERT INTO @ExpensesSELECT 1,10,15,0,'2012-01-19','James' UNION ALL SELECT 2,5,5,5,'2012-01-20','James'SELECT [Date]    ,CASE WHEN Category IS NULL AND [Date] IS NULL THEN 'Total'        WHEN Category IS NULL THEN 'Subtotal'        ELSE Category END    ,Expense=SUM(Expense)FROM @ExpensesCROSS APPLY (    VALUES ('Travel Expense', [Travel Expense])        ,('Stay Expense', [Stay Expense])        ,('Mis Expens', [Mis Expens])) a(Category, Expense)GROUP BY Date, Category WITH ROLLUP[/code]</description><pubDate>Mon, 28 Jan 2013 23:50:36 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>group wise sum query</title><link>http://www.sqlservercentral.com/Forums/Topic1412764-392-1.aspx</link><description>I have a table in the below format.S.no Travel Expense Stay Expense  Mis Expens  Date                Employee 1	10		15		0     19/Jan/2012             James 2	5		5		5     20/Jan/2012             JamesI want to display the above records in below format.Date : 19/Jan/2012      Travel Expense  10			Stay Expens	15			Mis expense	0			Sub-Total	25Date : 20/Jan/2012      Travel Expense  5			Stay Expense	5			Mis Expense     5			Sub-Total       15			Total		40			</description><pubDate>Mon, 28 Jan 2013 23:10:42 GMT</pubDate><dc:creator>Raghunathan</dc:creator></item></channel></rss>