CREATE Table CO(CustID int, OfficerSID varchar(10), OfficerRank
tinyint)
Insert Into CO
VALUES (1, 'KURT', 1)
Insert Into CO
VALUES (1, 'ALEX', 2)
Insert Into CO
VALUES (1, 'COLIN', 3)
Insert Into CO
VALUES (1, 'RUSTY', 4)
Insert Into CO
VALUES (2, 'CAL', 2)
Insert Into CO
VALUES (2, 'VIN', 4)
Insert Into CO
VALUES (3, 'FIDA', 2)
Insert Into CO
VALUES (3, 'ZOTO', 1)
Insert Into CO
VALUES (4, 'ZARA', 3)
Insert Into CO
VALUES (4, 'MAIR', 2)
Insert Into CO
VALUES (5, 'tara', 4)
Insert Into CO
VALUES (5, 'sara', 4)
I have an output table which is primarily like a temp table and then i
run my reports just grabbing data from this table.
This table looks like
CREATE Table tbl_Output (CustID int, OfficerSID1 varchar(10),
OfficerSID2 varchar(10))
I need this table to be populated thus
The offierSID1 needs to filled with officer who are ranked highest, be
it 1,2,3 or 4
Then comes OfficerSID2 which need to be filled with secondhighest
ranking, be it 1, 2, 3, 4
There can be two officersid with same ranking so then both of them
would appear in hte output table
The output table is already populated with CustID. so i need update
statements to fill in the officersids
So the output needs to look like
1, Kurt, Alex
2, Cal, Vin
3, Zoto, Fida
4, Mair, Zara
5, Tara, Sara or 5, Sara, Tara
tinyint)
Insert Into CO
VALUES (1, 'KURT', 1)
Insert Into CO
VALUES (1, 'ALEX', 2)
Insert Into CO
VALUES (1, 'COLIN', 3)
Insert Into CO
VALUES (1, 'RUSTY', 4)
Insert Into CO
VALUES (2, 'CAL', 2)
Insert Into CO
VALUES (2, 'VIN', 4)
Insert Into CO
VALUES (3, 'FIDA', 2)
Insert Into CO
VALUES (3, 'ZOTO', 1)
Insert Into CO
VALUES (4, 'ZARA', 3)
Insert Into CO
VALUES (4, 'MAIR', 2)
Insert Into CO
VALUES (5, 'tara', 4)
Insert Into CO
VALUES (5, 'sara', 4)
I have an output table which is primarily like a temp table and then i
run my reports just grabbing data from this table.
This table looks like
CREATE Table tbl_Output (CustID int, OfficerSID1 varchar(10),
OfficerSID2 varchar(10))
I need this table to be populated thus
The offierSID1 needs to filled with officer who are ranked highest, be
it 1,2,3 or 4
Then comes OfficerSID2 which need to be filled with secondhighest
ranking, be it 1, 2, 3, 4
There can be two officersid with same ranking so then both of them
would appear in hte output table
The output table is already populated with CustID. so i need update
statements to fill in the officersids
So the output needs to look like
1, Kurt, Alex
2, Cal, Vin
3, Zoto, Fida
4, Mair, Zara
5, Tara, Sara or 5, Sara, Tara
Comment