qq_29357869 2018-04-16 06:36 采纳率: 50%
浏览 2300
已采纳

SQL去重问题(应该是比较高级的去重?)

原题:
List the names of all the pairs of U.S. counties that touch each other only in a point (or multiple points, but not lines). Make sure to list each pair only once, and sort results alphabetically by the name of the first county in a pair and then by the name of the second county.

问题:
如何保证每一对只显示一次?(make sure to list each pair only once)。

举例:
返回的记录是:
1 A B
2 A C
3 A D
4 B A

我们视 1 和 4 是重复的, 如何去除

  • 写回答

9条回答 默认 最新

  • 咱姐夫 2018-04-16 07:43
    关注

    SELECT (CASE WHEN 第一列<第二列 THEN 第一列+第二列 ELSE 第二列+第一列 END) as AB from table group by AB

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(8条)

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?