我有一个如下查询:
SELECT cust.adm, COUNT(visits.visit_date) as visit_count FROM cust
LEFT JOIN visits ON cust.cust_id = visits.cust_id
WHERE cust.cust_id = 1
GROUP BY cust.adm
结果是:
adm | visit_count
--------------------------
TRUE | 0
如果adm为true,是否可以在'visit_count'上强制结果为'3'?
答案 0 :(得分:2)
您可以使用case
表达式:
SELECT cust.adm,
CASE cust.adm WHEN TRUE THEN 3 ELSE COUNT(visits.visit_date) END AS visit_count
FROM cust
LEFT JOIN visits ON cust.cust_id = visits.cust_id
WHERE cust.cust_id = 1
GROUP BY cust.adm
答案 1 :(得分:1)
这确实是迫使它。我能想到的就是不知道您要实现的目标。
jupyter labextension install @jupyter-widgets/jupyterlab-manager