sql - how to query the result of UNION query
问题描述
Thank you for your time and apologies if question is silly. I have a result of union query that looks like below. As you can see A and C both have value2 other then NULL. How I can select B only? I would provide my sql tries but I run out of ideas. I tried count() and sum() and other methods but I always select A B C while I want to get only B. Thank you.
value1 value2
A NULL
A 1
B NULL
C 2
C 3
C NULL
Thank you so much All for your help. I got the answer and much more! You all are awesome!
解决方案
这是你想要的吗?
select value1
from t
group by value1
having count(value2) = 0;
推荐阅读
- python - 如何解决泡菜编码?
- python - 如何在python中将firebase firestore geopoint转换为latlng
- django - 当您使用 DRF(Server API) + React(public Web Client) 时,如何实现 OAuth2 社交登录?
- azure - 确保 azure 管道构建的 dll 和 nuget 包包含与 csproj 版本相同的信息
- c++ - 使用对象名称后带有 [] 的类对象时,您究竟传递了什么。C++
- javascript - 我的程序正在“跳过”一个获取请求,React.js
- php - 如何在 Laravel 5.7 中获取当前用户详细信息?
- php - Foreach 循环仅返回最后一个结果
- winapi - Windows 10 1903 - LongPathAware 不工作?
- angular - 再次从angular8中的另一个组件调用组件的ngOnInit内部的逻辑