jayram11
Yak Posting Veteran
97 Posts |
Posted - 2011-05-20 : 09:50:40
|
Hicreate table #sort(PR varchar(5),val1 varchar (2),val2 varchar (2),val3 varchar (2),)insert into #sort(PR , val1, val2, val3)select 2345X , ‘AU’, ‘ZZ’, ‘BK’ union allselect 2345Y , ‘AU’, ‘KX, ‘BK’ union allselect 2345Y , ‘AU’, ‘BZ, ‘BK’ union allselect 2345Y , ‘XY’, ‘ZZ’, ‘BK’ union allselect 2345A , ‘AB’, ‘AA’, ‘BK’ union allselect 2345A , ‘AU’, ‘ZZ’, ‘BK’ union allselect 2345A , ‘AU’, ‘ZZ’, ‘BK’ union allselect 2345B , ‘AU’, ‘ZZ’, ‘’ union allselect 2345B , ‘AU’, ‘’, ‘BK’ union allselect 2345B , ‘AU’, ‘ZZ’, ‘BK’ union allselect 2345C, ‘AU’, ‘’, ‘AA’ union allselect 2345C , ‘AU’, ‘ZZ’, ‘BK’ union allselect 2345C , ‘’, ‘ZZ’, ‘BK’ union allselect 2345D , ‘AU’, ‘ZZ’, ‘’ this is kind of unique so was wondering i anyone could help mei want to sort the VAL variables horizontally in alphabetical orderif it is ‘’, ‘ZZ’, ‘BK’, i need to sort to ‘BK’, ‘ZZ’, ''if it 'AB', 'AA', 'AC', i need to sort to 'AA', 'AB', 'AC'empty values ('') should always be in last variable - Val3All help is appreciated... |
|