This could get ugly. I'll try to be as clear as possible.The following table is a segment of another table i had to use a pivot on (the pivoted rows/columns):CREATE TABLE [dbo].[abuestypedescpivoted]( [1930] [int] NULL, [1924] [int] NULL, [1927] [int] NULL, [1933] [int] NULL, [1934] [int] NULL, [1928] [int] NULL, [1931] [int] NULL, [1925] [int] NULL, [1932] [int] NULL, [1926] [int] NULL, [1929] [int] NULL) ON [PRIMARY]
The data in this table is being used to update fields in another table. In the destination table, i am only allowed to use three values total. There are entries in the source table where up to four or more columns contain data. My task is to first identify the rows where more than three columns have values, then, in numeric order of the column names above, use the first three columns which contain data. I would like to pull the extra columns out to another new table to create a concatenated narrative from. So, how do i first find the rows with more than three columns of data, and then order those by the column values (name of the column) and only use the three lowest values and move the extra data to the new table for the other task?1930 1924 1927 1933 1934 1928 1931 1925 1932 1926 1929NULL NULL 827177 NULL NULL NULL NULL NULL NULL NULL NULLNULL NULL 828975 NULL NULL NULL NULL NULL NULL NULL NULLNULL NULL 828975 NULL NULL NULL NULL NULL NULL NULL NULL881035 NULL 881035 NULL NULL NULL NULL NULL 881035 NULL 881035881035 NULL 881035 NULL NULL NULL NULL NULL 881035 NULL 881035NULL NULL 884596 NULL NULL NULL 884596 NULL NULL NULL 884596