Hi, "case" is function and operate on row data. If you have 7 rows then you got 7 rows after case To reduce rows you need to "group by" regards, Karol Bieniaszewki W dniu 2017-01-05 13:12:10 użytkownik 'Stef' [email protected] [firebird-support] <[email protected]> napisał: Good day everybody, I have the following query __________________________________________________________ ____________________ select D.NAME as NAME, (case (extract (Weekday from P.plandate )) when 1 then (P.PLANSTATUS) else '' end) as Monday, (case (extract (Weekday from P.plandate )) when 2 then (P.PLANSTATUS) else '' end) as Tuesday, (case (extract (Weekday from P.plandate )) when 3 then (P.PLANSTATUS) else '' end) as Wednesday, (case (extract (Weekday from P.plandate )) when 4 then (P.PLANSTATUS) else '' end) as Thursday, (case (extract (Weekday from P.plandate )) when 5 then (P.PLANSTATUS) else '' end) as Friday, (case (extract (Weekday from P.plandate )) when 6 then (P.PLANSTATUS) else '' end) as Saturday, (case (extract (weekday from P.plandate )) when 0 then (P.PLANSTATUS) else '' end) as Sunday from driverplan P join DRIVERS D on P.DRIVERNR = D.DRIVERNR where P.plandate >= '2017/01/01' order by 1 __________________________________________________________ ____________________ My question is why does it not return 1 row per driver, but instead I get 7 rows? Else how can I achieve this? Regards Stef van der Merwe Email [email protected] [Non-text portions of this message have been removed]
Re: [firebird-support] Case sql
liviuslivius [email protected] [firebird-support] Thu, 05 Jan 2017 06:54:53 -0800
- [firebird-supp... 'Stef' [email protected] [firebird-support]
- Re: [fire... liviuslivius [email protected] [firebird-support]
- RE: [... 'Stef' [email protected] [firebird-support]
- R... setysvar [email protected] [firebird-support]
