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(folderid) from folder
but I want the count of the number of unique combination of folderid and userid in the folder table. Is there a way to do this?
select count(*) from (
select distinct folderid, userid from folder
)
select count(*) from (
select folderId, userId
from folder
group by folderId, userId
) t
This will give you the count of unique folderid and userid combinations:
SELECT count(*)
FROM (
SELECT DISTINCT
folderid,
userid
FROM folder
);
Hope it helps...
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
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 ;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.