网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

如何在postgres里使用distinct去重复

时间:2024-11-20 17:02:26

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 FRO怡觎现喾M personORDER BY country_of_birth ASC;我们还可以进行去重后的排序。

如何在postgres里使用distinct去重复如何在postgres里使用distinct去重复

6、SELECT DISTINCT country_of_birth FRO怡觎现喾M personORDER 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去重复
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com