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
 SQL Server Development (2000)
 Creating a field value and a group by clause using a function

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-14 : 10:02:50
JackB writes "I am running this present query in SQL Server (Version 7.0) and Windows NT 4.0 SP5:

SELECT COUNT(Outbound.Date) AS Total_Calls, Employee.Dept, Month(Outbound.Date) AS For_Month FROM Outbound INNER JOIN Employee ON Outbound.EmployeeName = Employee.EmployeeName GROUP BY Employee.Dept, Month(Outbound.Date)
HAVING (MONTH(Outbound.Date)>= 9) AND (MONTH(Outbound.Date)<= 11)
ORDER BY Month(Outbound.Date)

Which produces this result:
Total_Calls                 Dept            For_Month  
----------- ----------- ---------
totalnbr deptnbr1 9
totalnbr deptnbr2 9
totalnbr deptnbr3 9
totalnbr deptnbr1 10
totalnbr deptnbr2 10
totalnbr deptnbr3 10
totalnbr deptnbr1 11
totalnbr deptnbr2 11
totalnbr deptnbr3 11


Is there any way to modify the above query so that it displays the data as follows:

Total_Calls                 Dept            For_Month_Year 
----------- ----------- --------------
totalnbr deptnbr1 9/00
totalnbr deptnbr2 9/00
totalnbr deptnbr3 9/00
totalnbr deptnbr1 10/00
totalnbr deptnbr2 10/00
totalnbr deptnbr3 10/00
totalnbr deptnbr1 11/00
totalnbr deptnbr2 11/00
totalnbr deptnbr3 11/00




Any assistance would greatly be appreciated."
   

- Advertisement -