question

sudumalli avatar image
sudumalli asked

Combine Separate row when using JOIN Staement

I used to join two tables and result got the seperate rows for the same mail Address i want to combine these thing, I used to below query for join two tables. SELECT EmailAddress AS Email,Name AS EName, (CASE WHEN [RecipientsReceivedType] = 'TO'THEN 1 ELSE 0 END) AS [RTO], (CASE WHEN [RecipientsReceivedType] = 'FROM'THEN 1 ELSE 0 END) AS [RFROM], (CASE WHEN [RecipientsReceivedType] = 'CC'THEN 1 ELSE 0 END) AS [RCC], (CASE WHEN [RecipientsReceivedType] = 'BCC'THEN 1 ELSE 0 END) AS [RBCC], 0 AS [STO], 0 AS [SCC], 0 AS [SBCC], 0 AS GrandTotalSent FROM tblRecipientsReceived UNION SELECT EmailAddress AS Email,Name AS EName, 0 AS [RTO], 0 AS [RFROM], 0 AS [RCC], 0 AS [RBCC], 0 AS GrandTotalReceived, (CASE WHEN [RecipientsSentType] = 'TO'THEN 1 ELSE 0 END) AS [STO], (CASE WHEN [RecipientsSentType] = 'CC'THEN 1 ELSE 0 END) AS [SCC], (CASE WHEN [RecipientsSentType] = 'BCC'THEN 1 ELSE 0 END) AS [SBCC] FROM tblRecipientsSent And it gave the below results. ![alt text][1] I want to combine those five rows in to one row( black rectangle in the Image) [1]: /storage/temp/3400-aaaa.png
sqlsqlquery
aaaa.png (25.5 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.