Sql 排除Qubole中具有特定值的记录
使用Qubole 我有 表A(json解析的列…) 我只需要选择推荐好但决策不好的ID。因此,输出应为3 我试过:Sql 排除Qubole中具有特定值的记录,sql,hadoop,hive,hiveql,qubole,Sql,Hadoop,Hive,Hiveql,Qubole,使用Qubole 我有 表A(json解析的列…) 我只需要选择推荐好但决策不好的ID。因此,输出应为3 我试过: SELECT a.ID FROM ( select json_parsed['ID'] as ID ,json_parsed["Decision"] as Decision ,json_parsed["Recommendation"] as Recommendation from A where create_date >=
SELECT a.ID
FROM (
select json_parsed['ID'] as ID
,json_parsed["Decision"] as Decision
,json_parsed["Recommendation"] as Recommendation
from A
where create_date >= '2020-11-18') a
Left JOin
(select json_parsed['ID'] as ID
,json_parsed["Decision"] as Decision
,json_parsed["Recommendation"] as Recommendation
from A
where create_date >= '2020-11-18') as b on a.ID = b.ID and b.Recommendation = "GOOD"
Where
b.Recommendation is NULL
使用分析函数 演示: 结果:
id recommendation decision
3 GOOD BAD
使用分析函数 演示: 结果:
id recommendation decision
3 GOOD BAD
decision
字段中的值似乎错误-根据您的逻辑,它应该是FAIL、NULL
等。?你能纠正一下吗?@KoushikRoy谢谢,我纠正了。你能试试这个吗?当推荐=GOOD,决策=BAD-选择json_-parsed['ID']作为ID,json_-parsed[“Decision”]作为Decision,json_-parsed[“推荐”]作为create_date>='2020-11-18'和json_-parsed[“Decision”]=“BAD”和json_-parsed[“推荐”]='GOOD'
此查询还返回建议为“GOOD”的ID,例如ID2,但我需要排除这些ID。在完美的场景中,我只想看到ID 3,它只有很好的推荐。问题与这里相同,但提供的解决方案似乎不在Qubole中工作。decision
字段中的值似乎错误-根据您的逻辑,它应该是失败、NULL
等。?你能纠正一下吗?@KoushikRoy谢谢,我纠正了。你能试试这个吗?当推荐=GOOD,决策=BAD-选择json_-parsed['ID']作为ID,json_-parsed[“Decision”]作为Decision,json_-parsed[“推荐”]作为create_date>='2020-11-18'和json_-parsed[“Decision”]=“BAD”和json_-parsed[“推荐”]='GOOD'
此查询还返回建议为“GOOD”的ID,例如ID2,但我需要排除这些ID。在完美的场景中,我只想看到ID 3,它只有很好的推荐。问题与这里相同,但是提供的解决方案在Qubole中似乎不起作用。
id recommendation decision
3 GOOD BAD