SQL - how to count unique combination of columns

前端 未结 5 926
孤城傲影
孤城傲影 2021-02-04 01:39

I\'m not sure if this is possible but I want to count the number of unique value in a table. I know to count the number of unique folderIDs I do:

select count(f         


        
相关标签:
5条回答
  • 2021-02-04 01:56
    select count(*) from (
        select folderId, userId
        from folder
        group by folderId, userId
    ) t
    
    0 讨论(0)
  • 2021-02-04 01:56
    select APPRSL_ID,SECTION_ID, count(APPRSL_ID||SECTION_ID)
    from REMARKSBYEACHSECTION 
    group by APPRSL_ID,SECTION_ID
    having count(APPRSL_ID||SECTION_ID)>1 ;
    
    0 讨论(0)
  • 2021-02-04 01:59

    This will give you the count of unique folderid and userid combinations:

    SELECT count(*)
      FROM (
            SELECT DISTINCT
                   folderid,
                   userid
              FROM folder
    );
    

    Hope it helps...

    0 讨论(0)
  • 2021-02-04 02:00
    select count(*) from (
      select distinct folderid, userid from folder
    )
    
    0 讨论(0)
  • 2021-02-04 02:00

    i think you can try to group the select statement with folder id

    eg.

    i have a table

    folderid userid

    1 11

    1 11

    2 12

    2 12

    3 13

    3 13

    Query is

    select count(folderid) from testtable group by folderid, userid
    
    0 讨论(0)
提交回复
热议问题