Link to home
Start Free TrialLog in
Avatar of Rayne
RayneFlag for United States of America

asked on

TSQL Help Missed Rows

Hello Gurus

There is a table called originalData that holds item specific information at a week level. There is a column called WeekTY.
Now I need a TSQL that does the following>>
There is another table called total end to end weeks that holds the number of total possible week values.
So, the sql simply looks for any combination of item + week that is NOT present in the originalData table and then adds them to the same table in this manner >>

 if item1+Week2 combination is missing in the originalData table, the sql basically duplicates all the row data for the combination of item1 + week1  but put zeroes for weekTY column only
Please see the attached. Tab “originalData” has the original rows and the tab “addedRows” has the entire data with the added new rows for the missed item + week combination
tsqlIssue.xlsx
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rayne

ASKER

Hello Portlet Paul,
it sql server 2010
Avatar of Rayne

ASKER

Thank you all
Avatar of Rayne

ASKER

Thank you all
Portlet Paul's solution was closest to what looked for