Click here to Skip to main content
16,022,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please i want to display daily report like this

Fulltime Contract Casual
2018/06/04 1 0 0
2018/06/05 1 0 0
2018/06/06 0 1 1
2018/06/07 2 1 0
2018/06/08 1 1 1
2018/06/09 0 1 1

but what i have is like this

Date Jobtype Meal
2018/06/04 Fulltime 1
2018/06/05 Fulltime 1
2018/06/06 Casual 1
2018/06/06 Contract 1
2018/06/07 Casual 1
2018/06/07 Contract 2
2018/06/08 Casual 1
2018/06/08 Contract 1
2018/06/08 Fulltime 1
2018/06/09 Casual 1
2018/06/09 Contract 1

What I have tried:

select Date,Jobtype ,'Meal'=(COUNT(WW)) from CanLog where WW BETWEEN '2018/06/06' and '2018/06/09' group by Date,Jobtype order by 1

please help
Posted
Updated 8-Jun-18 1:09am
Comments
CHill60 8-Jun-18 4:34am    
Use the improve question link to show us some sample data from the CanLog table. Why are you calculating a thing called 'Meal' when you don't want it in your final results?
In the meantime I think this is the technique you need - Simple Way To Use Pivot In SQL Query[^]

1 solution

You need to pivot[^] data:
SQL
SELECT Date, [Fulltime], [Contract], [Casual]
FROM (
    SELECT Date, JobType, WW
    FROM CanLog
    WHERE WW BETWEEN '2018/06/06' and '2018/06/09'
) AS DT
PIVOT(COUNT(WW) FOR Jobtype IN([Fulltime], [Contract], [Casual])) AS PVT
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900