Skip to content

Conversation

@SyedaFarhath
Copy link

I am a beginner learning PostgreSQL so I tried this alternate solution just a minute change.

Following your repos really helpful Thankyou.

@pratik221b
Copy link

is this correct ?

SELECT TRANSACTION_COUNT, COUNT(VISIT_DATE) AS VISITS_COUNT
FROM
(

SELECT A.USER_ID, A.VISIT_DATE, SUM( CASE WHEN B.TRANSACTION_DATE IS NULL THEN 0 ELSE 1 ) AS TRANSACTIONS_COUNT
FROM VISITS A LEFT JOIN TRANSACTIONS B ON A.USER_ID=B.USER_ID AND A.VISIT_DATE=B.TRANSACTION_DATE
GROUP BY 1,2

)
GROUP BY 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants