为什么我似乎不能同时按 2 列排序?
Why I can't seem to order by 2 columns at the same time?
我目前在这里遇到了这个问题。我正在尝试按 DESC 顺序订购 2 列,但一次似乎只有一列有效。我需要在 DESC 中订购 Main_Actor_Payment 和 Supporting_Actor_Payment,但它似乎不起作用。请有人帮我解决这个问题。
SELECT main_actor.First_Name,
main_actor.Last_Name,
main_actor.Payment_amount AS MAIN_ACTOR_PAYMENT,
supporting_actors.First_Name,
supporting_actors.Last_Name,
supporting_actors.Payment_amount AS SUPPORTING_ACTOR_PAYMENT
FROM main_actor
INNER JOIN supporting_actors USING(MOVIE_ID)
ORDER BY supporting_actors.Payment_amount DESC, main_actor.Payment_amount DESC;
Current output of query
如果我很好地理解你的问题,你需要合并 supporting_actors
和 main_actors
表以获得特定的 movie_id
,然后根据 payment_ammount
对它们进行降序排序(主要演员和配角)。如果这是你的意思,你可以使用这个查询:
SELECT * FROM (
SELECT main_actor.First_Name,
main_actor.Last_Name,
main_actor.Payment_amount AS `Payment_Ammount`,
"main_actor" as `Actor_Type`,
MOVIE_ID
FROM
main_actor
union all
SELECT
supporting_actors.First_Name,
supporting_actors.Last_Name,
supporting_actors.Payment_amount AS `Payment_Ammount`,
"supporting_actor" as `Actor_Type`,
MOVIE_ID
FROM
supporting_actors) a
WHERE a.MOVIE_ID = "La La Land"
ORDER BY a.`Payment_Ammount` DESC;
我目前在这里遇到了这个问题。我正在尝试按 DESC 顺序订购 2 列,但一次似乎只有一列有效。我需要在 DESC 中订购 Main_Actor_Payment 和 Supporting_Actor_Payment,但它似乎不起作用。请有人帮我解决这个问题。
SELECT main_actor.First_Name,
main_actor.Last_Name,
main_actor.Payment_amount AS MAIN_ACTOR_PAYMENT,
supporting_actors.First_Name,
supporting_actors.Last_Name,
supporting_actors.Payment_amount AS SUPPORTING_ACTOR_PAYMENT
FROM main_actor
INNER JOIN supporting_actors USING(MOVIE_ID)
ORDER BY supporting_actors.Payment_amount DESC, main_actor.Payment_amount DESC;
Current output of query
如果我很好地理解你的问题,你需要合并 supporting_actors
和 main_actors
表以获得特定的 movie_id
,然后根据 payment_ammount
对它们进行降序排序(主要演员和配角)。如果这是你的意思,你可以使用这个查询:
SELECT * FROM (
SELECT main_actor.First_Name,
main_actor.Last_Name,
main_actor.Payment_amount AS `Payment_Ammount`,
"main_actor" as `Actor_Type`,
MOVIE_ID
FROM
main_actor
union all
SELECT
supporting_actors.First_Name,
supporting_actors.Last_Name,
supporting_actors.Payment_amount AS `Payment_Ammount`,
"supporting_actor" as `Actor_Type`,
MOVIE_ID
FROM
supporting_actors) a
WHERE a.MOVIE_ID = "La La Land"
ORDER BY a.`Payment_Ammount` DESC;