Tamil Selvan

Tamil Selvan

  • 1.6k
  • 155
  • 6.7k

I need query for three table with join

Oct 7 2020 3:27 AM
Dear all,
 
Kindly find below table records for sample data.
 
TABLE-01

Dept Total No of codes
A 1191
B 1039
C 2012
D 3780
E 9
F 5972
G 2186






TABLE-02

user dept
U1 A
U2 A
U3 B
U4 C
U5 E
U6 G






TABLE-03

USER VAL1 date
U1 1001 06-10-2020
U2 1002 06-10-2020
U4 1004 06-10-2020
U3 1003 07-10-2020
U4 1005 07-10-2020
U4 1004 07-10-2020
U4 1006 08-10-2020
U5 1005 08-10-2020
U3 1003 09-10-2020
U6 1006 09-10-2020
 
An I need result as below:

Result





Dept Total No of codes Total CompletedCodes 06-10-2020 07-10-2020 08-10-2020 09-10-2020
A 10 2 2 0 0 0
B 20 2 0 1 0 1
C 15 4 1 2 1 0
D 30 0 0 0 0 0
E 9 1 0 0 1 0
F 44 0 0 0 0 0
G 58 1 0 0 0 1
total 186 10 3 3 2 2

Please find below image for your ref.



Answers (6)