![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
This is called pivoting and here is one solution: SELECT [Group], * * * *AVG(Cost) AS average_cost, * * * *COUNT(CASE WHEN Status = 'Planned' THEN 1 END) AS count_planned, * * * *COUNT(CASE WHEN Status = 'InProgress' THEN 1 END) AS count_inprogress, * * * *COUNT(CASE WHEN Status = 'Done' THEN 1 END) AS count_done FROM Items GROUP BY [Group]; -- Plamen Ratchevhttp://www.SQLStudio.com |
![]() |
| Thread Tools | |
| Display Modes | |
| |