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 2000 Forums
 Transact-SQL (2000)
 Display data according to financial year

Author  Topic 

chandan_joshi80
Starting Member

30 Posts

Posted - 2008-06-19 : 05:49:20
I have data like

June 13500.00 22000.00 1400.00 .00 7100.00
July 1500.00 2000.00 1000.00 .00 7600.00

but i want to display it according to financial year :
March 0 0 0 0
April 0 0 0 0
May 0 0 0 0
June 13500.00 22000.00 1400.00 .00 7100.00
July 1500.00 2000.00 1000.00 .00 7600.00

How it will possible




chandan Joshi

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-19 : 06:00:31
http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-19 : 06:02:39
SELECT month, sum(col1) AS col1, sum(col2) as col2, sum(col3) as col3, sum(col4) as col4
FROM (
{your original query here}

UNION ALL select 'march', 0, 0, 0, 0
UNION ALL select 'april', 0, 0, 0, 0
UNION ALL select 'may', 0, 0, 0, 0
UNION ALL select 'june', 0, 0, 0, 0
UNION ALL select 'july', 0, 0, 0, 0

) AS f
group by month


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-19 : 08:12:25
[code]SELECT mnths.Month,ISNULL(q.Field1,0.00),ISNULL(q.Field2,0.00),...
FROM
(SELECT 'March' AS Month, 1 AS Order
UNION ALL
SELECT 'April'AS Month, 2 AS Order
UNION ALL
SELECT 'May' AS Month, 3 AS Order
....
UNION AL
SELECT 'February' AS Month,12 AS Order)mnths
LEFT JOIN
{yourqueryhere}q
ON mnths.Month=q.monthcolumn
ORDER BY mnths.Order[/code]
Go to Top of Page
   

- Advertisement -