question

AtherrAlam-1408 avatar image
0 Votes"
AtherrAlam-1408 asked PRADEEPCHEEKATLA-MSFT commented

union operation with sum

I am looking for a way to combine two tables with the same fields in a way that the devicename which is common between the two gets added
See below example

2 tables a and b, with identical columns, I want to union them, so one column is device name other is error count, if I use union, will the count column be summed itself, or we have to do something else, i.e.

T1
devicename error count
a 10
b 12
c 15

T2
devicename error count
b 77
c 88
d 99
e 15
f 19

union T1, T2


Current result
a 10
b 12
c 15
b 77
c 88
d 99
e 15
f 19



Intended result

a 10
b 89
c 103
d 99
e 15
f 19


Please let me know if I need to use some other method for the intended results.

azure-data-explorer
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @AtherrAlam-1408,

Following up to see if the below suggestion was helpful. And, if you have any further query do let us know.


  • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.

0 Votes 0 ·

1 Answer

PRADEEPCHEEKATLA-MSFT avatar image
0 Votes"
PRADEEPCHEEKATLA-MSFT answered PRADEEPCHEEKATLA-MSFT commented

Hello @AtherrAlam-1408,

Welcome to the Microsoft Q&A platform.

You may use the below query to get the intended result as per your requirement.

  T1 | union T2
 | summarize sum(Value) by ID
 | order by ID asc

142391-image.png

Hope this will help. Please let us know if any further queries.


  • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how

  • Want a reminder to come back and check responses? Here is how to subscribe to a notification

  • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators


image.png (36.9 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @AtherrAlam-1408,

Just checking in to see if the above answer helped. If this answers your query, do click Accept Answer and Up-Vote for the same. And, if you have any further query do let us know.

0 Votes 0 ·