如何在postgres里使用distinct去重复

 时间:2026-04-21 15:40:37

1、打开命令行窗口,sudo su postgres进入数据库。

如何在postgres里使用distinct去重复

如何在postgres里使用distinct去重复

2、\c test进入test数据库。

如何在postgres里使用distinct去重复

3、SELECT * FROM person;

提取一下数据查看一下。

如何在postgres里使用distinct去重复

4、SELECT DISTINCT country_of_birth FROM person;

这样我们提取的时候就能够去掉重复的数据。

如何在postgres里使用distinct去重复

如何在postgres里使用distinct去重复

5、SELECT DISTINCT country_of_birth FROM person

ORDER BY country_of_birth ASC;

我们还可以进行去重后的排序。

如何在postgres里使用distinct去重复

如何在postgres里使用distinct去重复

6、SELECT DISTINCT country_of_birth FROM person

ORDER BY country_of_birth DESC;

降序也是可以的。

如何在postgres里使用distinct去重复

如何在postgres里使用distinct去重复

7、SELECT DISTINCT country_of_birth, gender FROM person;

我们可以对两个列同时去重,但是只会去重前面的那个。

如何在postgres里使用distinct去重复

如何在postgres里使用distinct去重复

8、不能同时用两个DISTINCT。

如何在postgres里使用distinct去重复

如何在postgres里使用distinct去重复

如何在postgres里使用distinct去重复

  • 如何关闭《西瓜视频》的“推送通知”功能?
  • 如何设置xshell按当前窗口大小排列层叠窗口?
  • ElasticSearch学习--批量操作命令之Bulk API
  • 天天看高清影视如何启用VMR9渲染方式
  • VirtualDJ怎么设置当前切点播放时循环保持播放
  • 热门搜索
    心肌炎是怎么引起的 颜色用英语怎么说 梅菜扣肉的做法视频 手肿胀是怎么回事 手机充电慢是怎么回事 静脉曲张怎么治疗 植物医生护肤品怎么样 青萝卜怎么做好吃 谢贤为什么打曾江 说明书怎么写