MySQL Forums
Forum List  »  Newbie

Re: Case When help
Posted by: Peter Brawley
Date: July 24, 2021 06:29PM

Unfortunately the query contradicts itself---Left Joining to d then stipulating CASE WHEN d.DeviceStatus != '99'AND d.publishedstatus !='99' AND d.LocationType NOT IN ('Home'), thereby turning the Left Join into an Inner Join, so you need to rethink those Left Joins.

To rejig ... CASE WHEN ... THEN 1 ELSE 0 so it returns counts ...

Select SUM(CASE WHEN ... THEN 1 ELSE 0 ) AS ..., essentially you write a pivot table, see that topic at https://www.artfulsoftware.com/queries.php.



Edited 2 time(s). Last edit at 07/25/2021 11:57AM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
July 24, 2021 03:49PM
Re: Case When help
July 24, 2021 06:29PM
July 25, 2021 01:31AM
July 25, 2021 11:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.