Re: CASE and common table expression in mysql
Converting the query to conventional subqueries ...
select
user_name, rating,
CASE rating
WHEN 0 THEN 'Really bad'
WHEN 1 THEN 'Bad'
WHEN 2 THEN 'Almost bad'
WHEN 3 THEN 'So-so'
WHEN 4 THEN 'OK'
ELSE 'Loved it!'
END AS rating_text
from (
select
a.user_name,
(FLOOR(0 + RAND() * (5 - 0))) AS rating
from (
SELECT 'Asher' as user_name
UNION ALL
SELECT 'Cyd'
UNION ALL
SELECT 'Joe'
) a
) b;
manifests the same problem, I think Rand() causes the inconsistency---you'd need to move that random generation out of the query to make the ratings match.
Subject
Written By
Posted
December 30, 2019 03:56PM
Re: CASE and common table expression in mysql
December 30, 2019 10:11PM
December 31, 2019 09:36AM
December 31, 2019 10:29AM
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.