jayram11
Yak Posting Veteran
97 Posts |
Posted - 2011-05-20 : 09:50:40
|
Hi
create 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 all select 2345Y , ‘AU’, ‘KX, ‘BK’ union all select 2345Y , ‘AU’, ‘BZ, ‘BK’ union all select 2345Y , ‘XY’, ‘ZZ’, ‘BK’ union all select 2345A , ‘AB’, ‘AA’, ‘BK’ union all select 2345A , ‘AU’, ‘ZZ’, ‘BK’ union all select 2345A , ‘AU’, ‘ZZ’, ‘BK’ union all select 2345B , ‘AU’, ‘ZZ’, ‘’ union all select 2345B , ‘AU’, ‘’, ‘BK’ union all select 2345B , ‘AU’, ‘ZZ’, ‘BK’ union all select 2345C, ‘AU’, ‘’, ‘AA’ union all select 2345C , ‘AU’, ‘ZZ’, ‘BK’ union all select 2345C , ‘’, ‘ZZ’, ‘BK’ union all select 2345D , ‘AU’, ‘ZZ’, ‘’
this is kind of unique so was wondering i anyone could help me
i want to sort the VAL variables horizontally in alphabetical order
if 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 - Val3 All help is appreciated...
|
|