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
  • 相关阅读:
    《需求规格说明书》的工作流程、组员分工和组员工作量比例
    电子公文传输系统 需求分析
    电子公文传输系统 团队展示
    团队作业(三)
    2.3.1测试
    缓冲区溢出漏洞实验
    cat userlist
    ls的功能
    团队作业(二)——需求分析
    C语言中的函数、数组与指针
  • 原文地址:https://www.cnblogs.com/chenjunbiao/p/1760189.html
Copyright © 2011-2022 走看看