Hi guys,

I am having this small difficulty in restructuring a query.

I have a table called invoice which has these fields:

Month - the number of months between date invoice was entered and current date.

I need to generate a report which shows the department and sum of amounts for the each month AS

Dept 1 month 2 month 3month 4 months >4 months

Dept1 12000 353535 560000 5698898 125125445
Dept2 12340 45550 545200 5698898 125125445
Dept3 13450 25650 458700 5698898 125125445
Dept4 11230 28950 125400 5698898 125125445
Dept5 11230 22120 365400 5698898 125125445

This represents the sum of amounts for the last 1 month for Dept1,last 2 months for DEpt1 and so on...

Can anyone help me to get a query in this manner.

I can get the values in the following manner:

Dept1 1month 12000
Dept1 2 month 353535
Dept1 3month 560000
Dept2 1 mopnt 12340
Dept2 2 month 45550

How can i make this in a horizonal manner instead of a vertical manner.

SELECT d.Dept_Name AS Department, c.Month, Sum(c.[Total Amount]) AS Total FROM CurrentOutstanding AS c, Department AS d
WHERE (((c.Dept_Id)=[d].[Dept_id]))
GROUP BY d.Dept_Name, c.Month;

This is the query i use for the amove result set.

Thanks and appreciate any help.