Thursday, 12 September 2013

COMPARE 2 COLUMNS IN 2 TABLES WITH DISTINCT VALUE

COMPARE 2 COLUMNS IN 2 TABLES WITH DISTINCT VALUE

I am now creating a reporting service with visual business intelligent.
i try to count how many users have been created under an org_id.
but the report consist of multiple org_id. and i have difficulties on
counting how many has been created under that particular org_id.
TBL_USER
USER_ID
0001122 0001234 ABC9999
DEF4545 DEF7676
TBL_ORG
ORG_ID
000 ABC DEF
EXPECTED OUTPUT
TBL_RESULT
USER_CREATED
000 - 2 ABC - 1 DEF - 2
in my understanding, i need nested SELECT, but so far i have come to nothing.
SELECT COUNT(TBL_USER.USER_ID) AS Expr1 FROM TBL_USER INNER JOIN TBL_ORG
WHERE TBL_USER.USER_ID LIKE 'TBL_ORG.ORG_ID%')
this is totally wrong. but i hope it might give us clue.

No comments:

Post a Comment