Skip to content
Advertisement

how to do sum with multiple joins in PostgreSQL?

I know that my question would be duplicated but I really don’t know how to created sql which return results of sum with multiple join.

Tables I have

result_summary

summary_assembly

employees

info_product

machine

query

result

expected output(when sum by num_lot)

All of them were modified from original one because they were non-English, so there would be typo.

Here now I need to sum by num_lot, name_product or sabun. id_summary is unique.

Thanks

Advertisement

Answer

As expected in the comments: It seems like you simple need a subquery which groups your table by the column num_lot

It was asked in the comments what the s stands for: A subquery needs an alias, an identifier. Because I didn’t want to think about a better name, I just called the subselect s. It is the shortcut for AS s

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement