如果我有这样的查询
$line_item_status_query =
"SELECT p.description,
p.production_order_id,
l.start_user,
p.sequence,
l.start :: date,
l.stop :: date,
pr.id,
pr.process,
pr.process_sequence,
pr.caption_in_process,
pr.caption_closed,
pr.show_to_customer
FROM production_order_processes p
LEFT JOIN production_order_process_log l
ON l.production_order_process_id = p.id
LEFT JOIN processes pr
ON pr.process_sequence = p.sequence
WHERE l.production_order_id = (SELECT id
FROM production_orders
WHERE
sales_order_line_id = '".$sales_order_line_id."')
ORDER BY p.sequence";
和l.start :: date
/或l.stop :: date
可能为空或为空,我该怎么做ORDER BY
才能根据最近的日期将返回的结果按升序(或降序)排列?
我想用一些条件逻辑替换 p.sequence 的顺序,但我已经超出了我的深度。
谢谢你的帮助!