0

I just want to count duplicated dae columnds in my table. My tables are like that:

VISIT:

ID_VISIT FK_PATIENT DATEA
0        1          20160425
1        2          20160425
2        3          20160426

I tried these :

SELECT VISIT.DATEA, COUNT(VISIT.DATEA) as numberOfDate FROM VISIT
SELECT VISIT.DATEA, COUNT(VISIT.DATEA) as numberOfDate FROM VISIT GROUP BY numberOfDate

but I got only like this :

DATEA    NUMBEROFDATE
20160502 1
20160430 1
20160503 1
20160501 1
20160429 1
20160425 1
20160425 1
20160425 1
20160428 1
20160504 1

but I want to get like this

DATEA    NUMBEROFDATE
20160502 1
20160430 1
20160503 1
20160501 1
20160429 1
20160425 3
20160428 1
20160504 1

1 Answer 1

2

Group by the column you want to be unique. Then aggregate functions like count() apply to each group

SELECT DATEA, COUNT(DATEA) as numberOfDate 
FROM VISIT 
GROUP BY DATEA
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.