如何“按分钟排序(子查询)”?
我正在尝试返回日期列表。每行都有多个日期连接为一个字符串。我想按每行中的最小日期对行进行排序。
这是我的查询:
SELECT br.bm_tracking_number,
(SELECT TOLIST(APPT.fact_date)
FROM bm_fact APPT
WHERE APPT.bm_review_sk = br.bm_review_sk
AND APPT.fact_type_code=183050) "Appointments"
FROM BM_REVIEW br
WHERE row_delete_date_time IS NULL
ORDER BY MIN(SELECT APPT.fact_date
FROM bm_fact APPT
WHERE APPT.bm_review_sk = br.bm_review_sk
AND APPT.fact_type_code = 183050);
我在按行排序时收到 Oracle 错误(00936 缺少表达式)。还有另一种方法可以完成我想做的事情吗?
I am trying to return a list of dates. Each row has multiple dates concatenated as a single string. I want to order the rows by the minimum date in each row.
Here is my query:
SELECT br.bm_tracking_number,
(SELECT TOLIST(APPT.fact_date)
FROM bm_fact APPT
WHERE APPT.bm_review_sk = br.bm_review_sk
AND APPT.fact_type_code=183050) "Appointments"
FROM BM_REVIEW br
WHERE row_delete_date_time IS NULL
ORDER BY MIN(SELECT APPT.fact_date
FROM bm_fact APPT
WHERE APPT.bm_review_sk = br.bm_review_sk
AND APPT.fact_type_code = 183050);
I am getting an Oracle error (00936 missing expression) on the order by line. Is there another way to accomplish what I am trying to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这:
...将为您提供一个列表,按
fact_date
升序排列。This:
...will give you a list, ordered by the
fact_date
in ascending order.只看了一眼,但有一件事是您没有在子查询中将 bm_fact 别名为 APPT。
编辑:
好的,你解决了这个问题。
将 MIN() 放在子查询中怎么样?
Only glancing at it, but one thing is that you didn't alias bm_fact to APPT in the subquery.
EDIT:
Okay, you fixed that.
How about putting the MIN() inside the sub query?