Home Postgresql returning repeating data on multiple join
Reply: 0

Postgresql returning repeating data on multiple join

user619
1#
user619 Published in April 26, 2018, 1:44 pm

I can't figure out why my output is duplicating, but I'm sure it is incorrect joins. I'm new to SQL in general, so this may be an inefficent query.

SELECT a.id, a.number, a.number2, b.id, b.number3, b.number4, c.id, c.score, (a.number - b.number3) as a_b_difference, (a.number2 - b.number4) as a_b_difference3 FROM file a
INNER JOIN file b on a.id = b.id
INNER JOIN file c on a.id = c.id

I want to subtract the two fields and combine all three files on the id. However, my result populates with repeating data.

This is a sample of what I am getting:

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.573493 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO