M
M
Ms123412342020-11-20 11:20:38
SQL
Ms12341234, 2020-11-20 11:20:38

How to write valid SQL query with CASE construct?

Query construction - SELECT ts CASE description WHEN 'bad' THEN 'rain,storm' ELSE 'good' END weather_conditions FROM weather_records;
The terminal swears at such a request.

in the task, you need to isolate the data for each hour and divide the data into bad and good.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2020-11-20
@FFOX

SELECT ts CASE description WHEN 'bad' THEN 'rain,storm' ELSE 'good' END weather_conditions FROM weather_records;
correct like this:
SELECT CASE WHEN description 'bad' THEN 'rain,storm' ELSE 'good' END AS weather_conditions FROM weather_records;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question