zoukankan      html  css  js  c++  java
  • Question[SQL]:Can you use a SQL statement to finding duplicate values!

    Question:Can you use a SQL statement to finding duplicate values!
    How can I find authors with the same last name?
    You can use the table authors in datatabase pubs. I want to get the result as below:
    Output:
    au_lname   number_dups
    ---------------------------------------- -----------
    Ringer  2

    (1 row(s) affected)

    Answer:

        if OBJECT_ID('dbo.Table101302'is not null
            
    drop table dbo.Table101302
        
    create table dbo.Table101302
        (
            
    [Id] int,
            
    [au_lname] varchar(10)
        )
        
    insert into dbo.Table101302 values(1'name1')
        
    insert into dbo.Table101302 values(2'name2')
        
    insert into dbo.Table101302 values(3'name3')
        
    insert into dbo.Table101302 values(4'name3')
        
    insert into dbo.Table101302 values(5'name4')
        
    insert into dbo.Table101302 values(6'name5');
        
    insert into dbo.Table101302 values(7'name5');
        
        
    select [au_lname][number_dups]=COUNT(1)
            
    from dbo.Table101302
            
    group by [au_lname]
            
    --having(COUNT(1)>1)

        
    drop table dbo.Table101302
  • 相关阅读:
    数据导入和导出
    用户登陆案例
    SQLHelper
    把连接数据库的字符串放在配置文件中
    访问数据库
    SQL语句
    Django Tornado Flask
    Python 的协程
    面试 Better Call Soul
    mklink 解决VScode 扩展...Google迁移到 windows D盘
  • 原文地址:https://www.cnblogs.com/chenjunbiao/p/1760189.html
Copyright © 2011-2022 走看看