Hi there. I have a problem. Cant get exclusive data from a simple relation. I have this:DECLARE @CATALOG TABLE (RangeNumber Integer, RangeDesc Varchar(50))INSERT INTO @CATALOG select 1,'1. 0 Days' UNIONselect 2,'2. To 30 Days' UNIONselect 3,'3. To 60 Days' UNIONselect 4,'4. To 90 Days' UNIONselect 5,'5. To 120 Days' UNIONselect 6,'6. To 180 Days' UNIONselect 7,'7. To 360 Days' UNIONselect 8,'8. + 360 Days' UNIONselect 9,'9. Due'DECLARE @DATA TABLE (MonthNumber Integer, RangeNumber Integer, Balance Decimal(18,2))INSERT INTO @DATASELECT 1,1,1330.22 UNIONSELECT 1,1,1108137210.22 UNIONSELECT 1,2,60761625.83 UNIONSELECT 1,3,22261917.52 UNIONSELECT 1,4,8706707.32 UNIONSELECT 1,8,15397510.09 UNIONSELECT 2,1,3453 UNIONSELECT 2,2,345 UNIONSELECT 2,3,43534 UNIONSELECT 2,6,345334 UNIONSELECT 2,7,35345
I want to add rows in Data table from ranges that i dont have in data table but i have in the Catalog.I want to Add the following list:SELECT 1,5,0 UNIONSELECT 1,6,0 UNIONSELECT 1,7,0 UNIONSELECT 1,8,0 UNIONSELECT 2,4,0 UNIONSELECT 2,5,0 UNIONSELECT 2,8,0 UNIONSELECT 2,9,0
Notice that in month number 1, i didnt have 5,6,7,8 and in month number 2 i didnt have 4,5,8,9 ranges, so i want to added with 0 Balance.How can i do these?