Sql - add row when not existed
- by Nguyen Tuan Linh
Suppose I have a query that returns result like this:
Project Year Type Amt
PJ00001 2012 1 1000
PJ00001 2012 2 1000
PJ00001 2011 1 1000
PJ00002 2012 1 1000
What I want: Every Project will have 2 rows of Types for each Year. If the row is not there, add it to the result with Amt = 0.
For example:
- PJ00001 have 2 rows of type 1,2 in…