Quantcast
Channel: MySQL Case statement in a View with Union All - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Nick for MySQL Case statement in a View with Union All

$
0
0

You can't use an alias in the SELECT, so you can't refer to records_waiting_count, you need to use the expression that it refers to. Also you already have a column called status, so you can't call the value of the CASE expression that (let's call it waiting_status instead). So your CASE expression should look like:

CASE WHEN ((SELECT COUNT(*) From location Where file_importer_id = fi.file_importer_id AND status = 'Y') +(SELECT COUNT(*) From reservation Where file_importer_id = fi.file_importer_id AND status = 'N') +(SELECT COUNT(*) From startup Where file_importer_id = fi.file_importer_id AND status in ('X', 'X1'))) > 0 THEN 'Waiting' ELSE 'Accepted' END AS waiting_status

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>