Avatar of tmajor99
tmajor99

asked on 

SQL Select - Populate empty column rows

Is it possible to have SQL Select populate columns from other columns conditionally?  For example; I have 1 table with four columns as follows;

Current Week Folder Name   Current-Product-Count              Prior Week Folder Name   Prior-Product-Count
Abrasives                                            98                                                         Abrasives                 100
                                                                                                                           Filters                            9
Conditioner                                    2100                                      
Plugs                                                    31                                                         Plugs                           31

What I want is to populate the empty column rows with either the current or prior week column so the file looks like this:

Current Week Folder Name   Current-Product-Count              Prior Week Folder Name   Prior-Product-Count
Abrasives                                            98                                                         Abrasives                 100
Filters                                                    0                                                         Filters                            9
Conditioner                                    2100                                                        Conditioner                  0
Plugs                                                    31                                                         Plugs                           31

As you can see I want to fill in the blank columns with the value the prior or current week,
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
ste5an

8/22/2022 - Mon