sql - 如何在sql中实现以下要求
解决方案
您可以使用exists
:
select t.*
from table t
where exists (select 1 from table t1 where t1.col2 = t.col2 and t1.col1 <> t.col1);
推荐阅读
- java - Gradle 运行任务不起作用 - 错误:--module-path 需要模块路径规范
- swift - MongoDB地理空间查询数组中的坐标
- cmake - 尝试添加自定义规则以输出 some/path/to/XXXX.rule 在 Windows 上的 qt5 cmake 中已经有自定义规则
- python - 按班级划分的频率
- sql - 按另一个属性执行分组时选择一个属性
- c++ - 使用字典进行本地化
- javascript - 检查一个文件路径是否存在于另一个文件路径中?
- python - pyautogui 和 schedule 不能一起工作
- java - gRPC Kotlin / Java 性能差异
- mongodb - 在 MongoDB 中存储格式为 YYYY-MM-DD 的日期的最佳方法是什么?