ITsolutionWizard
asked on
SQL Query Relationship
please take a look of the attached file. It is a simple invoice to receipt (1 to m) relationship. and my question is.
1. assume I give you receipt received to date range 01/01/2019 to 01/14/2019. how can get the following in SQL query.
Invoice ID Total Receipt Count Receipt Amount
1 25.00 1
2 0 0
3 0 0
1. assume I give you receipt received to date range 01/01/2019 to 01/14/2019. how can get the following in SQL query.
Invoice ID Total Receipt Count Receipt Amount
1 25.00 1
2 0 0
3 0 0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, above query will give one invoice per line..
ASKER
what is left and right join means...
Sorry, if you are very new to SQL JOINS, then I would suggest you to go through this wonderful article(series) about JOIN so that you would know about JOINs completely..
In simple words, LEFT JOIN will bring all records from LEFT tables and non matching records in RIGHT table will have NULL values.
RIGHT JOIN will bring all records from RIGHT table and non matching records in LEFT table will have NULL values.
https://sqlity.net/en/1146/a-join-a-day-introduction/
In simple words, LEFT JOIN will bring all records from LEFT tables and non matching records in RIGHT table will have NULL values.
RIGHT JOIN will bring all records from RIGHT table and non matching records in LEFT table will have NULL values.
https://sqlity.net/en/1146/a-join-a-day-introduction/
If you like Venn Diagrams and pictures, this is one of the best I've seen at explaining joins:
https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
ASKER