'how do I use multiple functions in sql?

I am a beginner in SQL and using PostgresSQL 14. I have two table customer and payment and the columns are.

customer table

customer_id int
first_name chr
email chr

payment table

customer_id int
payment_date date  
amount numeric

My desired output is to get customer id, email id and total amount paid by customer and payment_date.

This is my output using inner join.

enter image description here

Now I want to sum amount using GROUP BY, but how do I use INNER JOIN and GROUP BY together?

How do I run two different things together? Is there way to save output and work on it like a script?



Solution 1:[1]

Use in SELECT SUM(column_name) For your inner join, in GROUP BY you need to put everything you choose to show in select except for operations like SUMyou don't have to write it in group by.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1