Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
berryandcherry6
Creator II
Creator II

Get counts for each unique fieldvalues from multiple tables.

Hi,

Table1:

Batch_idInvitation_idComm_type_id
213222
313422
313523
213623
313723
313824

Table 2:

Batch_idInvitation_idComm_type_idUser_signed
2132221
3135231
3137231
4222220
2136231
3138240
3134221

From above tables, i want to get all  Comm_type_id  from Table1, and match invitation_id, Batch_id in Table2 where User_signed = 1 for each comm_type_id, find sum and append it to Table1

I want to create table like this

Batch_idInvitation_idComm_type_idsum(user_signed)
2132221
3134221
3135232
2136231
3137232
3138240

How could i do this? Let me know if you need more info on this.

13 Replies
kkkumar82
Specialist III
Specialist III

Hi supriya,

I think , if you match both the tables with invitation_id, Batch_id  for each comm_type in the third table for the first row you have to get 1 but how you got 2 ? because between table 1 and table 2 you have only one record for 2, 132 combinations.

berryandcherry6
Creator II
Creator II
Author

Hi,

Thanks

Yes, you are right. I have edited in query.

balar025
Creator III
Creator III

Is it irrespective of Invitation id?

because i can see to get sum(user_signed) you have used batch_id and comm_type_id.

is it right?

kkkumar82
Specialist III
Specialist III

Please close the thread if you feel you have got the answer.

berryandcherry6
Creator II
Creator II
Author

No, both invitations in Table1 and Table 2 must match.

balar025
Creator III
Creator III

But same count you are showing for all invitation in same batch_id and comm_type_id. Is it right?

Like 3 and 23 combination.

passionate
Specialist
Specialist

Hi Supriya,

In your requirement for BatchId=3 and invitationId=135 how did you get Sum as 2?

I think something is missing.

Regards,

Pankaj

balar025
Creator III
Creator III

Please find attached application that might help you.

berryandcherry6
Creator II
Creator II
Author

Hi,

for comm_type_id = 23, i have two rows which matches batch_id, inviation_id and comm_type_id in both the table where user_signed = 1

i.e 

213623
313723