human
Schema:
program (Program_ID, Name, Origin, Launch, Owner)
channel (Channel_ID, Name, Owner, Share_in_percent, Rating_in_percent)
broadcast (Channel_ID, Program_ID, Time_of_day)
broadcast_share (Channel_ID, Program_ID, Date, Share_in_percent)
Please answer with SQL.
assistant
Sure, I understand.
human
What are the names of the channels owned by CCTV or HBS?
assistant
SELECT name FROM channel WHERE OWNER = 'CCTV' OR OWNER = 'HBS'
human
what is the number of different channel owners?
assistant
SELECT count(DISTINCT OWNER) FROM channel
human
Find the total rating ratio for each channel owner.
assistant
SELECT sum(Rating_in_percent) , OWNER FROM channel GROUP BY OWNER
human
Find the names of the channels that are broadcast in the morning.
assistant
SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Morning'
human
What is the owner of the channel that has the highest rating ratio?
assistant
SELECT OWNER FROM channel ORDER BY rating_in_percent DESC LIMIT 1
human
Give me a list of all the channel names sorted by the channel rating in descending order.
assistant
SELECT name FROM channel ORDER BY rating_in_percent DESC ;