Advertisement
willianto

Mengambil no faktur dan sorting based on padding

Oct 3rd, 2016
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.65 KB | None | 0 0
  1. create table #test (NoFaktur varchar(20))
  2.  
  3. insert into #test Values ('999/DODOL/X/2016');
  4. insert into #test Values ('9/DODOL/X/2016');
  5. insert into #test Values ('1099/DODOL/X/2016');
  6. insert into #test Values ('892/DODOL/X/2016');
  7. insert into #test Values ('1096/DODOL/X/2016');
  8. insert into #test Values ('839/DODOL/X/2016');
  9. insert into #test Values ('59/DODOL/X/2016');
  10. insert into #test Values ('12/DODOL/X/2016');
  11. insert into #test Values ('3/DODOL/X/2016');
  12.  
  13. SELECT NoFaktur
  14.         , REPLACE (STR (CAST (Substring (NoFaktur, 1, CHARINDEX ('/', NoFaktur, 1)-1) AS INT), 4), SPACE(1), '0') as cNoFaktur
  15.   from #test
  16.   order by cNoFaktur
  17. Drop table #test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement