dongqu1783 2016-12-16 09:25 采纳率: 100%
浏览 424
已采纳

MySQL - 从表中选择唯一值

My MySQL table contains the following information,

ID  User            City            HomeLatitude      HomeLongitude
1   Egon Spengler   New York        19.123456         23.43546
2   Mac Taylor      New York        19.12343588       23.43546
3   Sarah Connor    New York        19.128376         34.35354
4   Jean-Luc Picard La Barre        11.345455         12.4356546
5   Ellen Ripley    Nostromo        32.76865          78.345435

From this table I need to query unique HomeLatitude values with first two decimal point because the first 3 location are almost same, so i need only the first row from the three rows..

I used the below given query,

SELECT DISTINCT HomeLatitude, City FROM user;

But that will return all the rows from the table. Can anyone help me on this.

  • 写回答

3条回答 默认 最新

  • dongwaner1367 2016-12-16 09:29
    关注

    ROUND Function will give you the number of decimal places that you want to show.

    SELECT DISTINCT ROUND(HomeLatitude,2), City FROM user GROUP BY ROUND(HomeLatitude,2);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题