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
List all channel names ordered by their rating in percent from big to small.
assistant
SELECT name FROM channel ORDER BY rating_in_percent DESC
human
Find the names of channels that are not owned by CCTV.
assistant
SELECT name FROM channel WHERE OWNER != 'CCTV'
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
find the total percentage share of all channels owned by CCTV.
assistant
SELECT sum(Share_in_percent) FROM channel WHERE OWNER = 'CCTV'
human
Find the total rating ratio for each channel owner.
assistant
SELECT sum(Rating_in_percent) , OWNER FROM channel GROUP BY OWNER
human
Count the number of distinct channel owners.
assistant
SELECT COUNT( DISTINCT OWNER ) FROM channel ;