带日期名称和多个order by子句的Oracle查询?

问题描述 投票:-1回答:1

因此,我有三个表:“剧院”,“表演”和“发布”。

ERD

剧院

1“布鲁克林” 2322“达拉斯” 423

发布

“”漫画“”进行漫画表演的演员““戏剧”,“演戏的演员”

显示

1“布鲁克林”“漫画” 2019-10-10 18:30:002“达拉斯”“戏剧” 2019-09-09 15:30:003“布鲁克林”“戏剧” 2019-08-08 08:00:004“布鲁克林”“漫画” 2019-07-07 19:00:005“ Dallas”“ Drammatics” 2019-09-09 14:30:00

我需要按剧院名称排序,然后按日期排序,然后按时间进行所有演出。需要按剧院名称,演员名称,日期(星期一..)和放映时间列出它们。

预期输出:

|  Theatre name  |  Cast name  |     Day     |Time of performance
     "Brooklyn"       "Comics"       "Sunday"      19:00:00
     "Brooklyn"       "Dramatics"    "Thursday"    08:00:00
     "Brooklyn"       "Comics"       "Thursday"    18:30:00
      "Dallas"        "Dramatics"    "Monday"      14:30:00
      "Dallas"        "Comics"       "Monday"      15:30:00

因此,首先需要按剧院名称排序,然后按日期和时间排序。

我真的坚持了这一点。感谢任何帮助:)

sql database oracle
1个回答
0
投票

您需要通过以下简单命令:

Select ...
From ...
Order by theatre_name, show_time -- show_time is date data type then it must include date and time both

要获取日期,请使用to_char(show_time, 'day'),并获取时间,请使用to_char(show_time,'hh24:mi:ss')。>>

请您自己在查询中加入联接和其他内容。

干杯!

© www.soinside.com 2019 - 2024. All rights reserved.