V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
reticentfat
V2EX  ›  问与答

oracle 如何保证某一个字段数值唯一

  •  
  •   reticentfat · Feb 14, 2015 · 3592 views
    This topic created in 4090 days ago, the information mentioned may be changed or developed.
    现在数据库里边有四个字段
    mobile,opttime,opttime,job_num
    我想从表1中提取不同mobile的值的,并附带相应其他三个字段的数值
    我写成如下
    select j.mobile, max(j.opttime), max(j.opttime) ,max(j.job_num)
    from 表1 j
    group by j.mobile
    但是数值与我
    select count (distinct j.mobile) from 表1 j 的数值不一样。
    请问我错在哪?应该如何实现?
    谢谢了!
    Supplement 1  ·  Feb 14, 2015
    可能刚才有点晕,现在一看数值一样了。给大家添麻烦了~我失礼了
    2 replies    2015-02-14 11:58:33 +08:00
    F281M6Dh8DXpD1g2
        1
    F281M6Dh8DXpD1g2  
       Feb 14, 2015
    count不算空值
    reticentfat
        2
    reticentfat  
    OP
       Feb 14, 2015
    @liprais 这四个字段都没有空值啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3198 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 13:41 · PVG 21:41 · LAX 06:41 · JFK 09:41
    ♥ Do have faith in what you're doing.