我正在尝试根据两个条件将MIN/MAX
应用于我的SELECT
子句。 (见下文)。当我尝试在另一个查询中引用我的列submitted_at
时,它表示列引用不明确。
MIN(CASE WHEN (document != 'dphoto' AND document_type != 'dlicenses' AND
status = 'upload') THEN occurred_at END) AS submitted_at,`
MAX(CASE WHEN (document_type = 'dphoto' AND document_type = 'dlicenses' AND
status = 'upload') THEN occurred_at END) AS submitted_at`
我试图将这个短语合并为1个选择,但一直没有成功。感谢任何提示
答案 0 :(得分:0)
您可以使用以下方法将两者合并为一列:
CASE WHEN (document != 'dphoto' AND document_type != 'dlicenses' AND status = 'upload')
THEN Min(occurred_at)
WHEN (document_type = 'dphoto' AND document_type = 'dlicenses' AND status = 'upload')
THEN Max(occurred_at)
END As Submitted_at