Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. table:example
  2. +--------------+--------------+-------------+
  3. | id_nr | code | subtype |
  4. +-------------------------------------------+
  5. | 1445 | 40D1343 | DRG |
  6. | 1445 | 23423asas | PROC |
  7. | 1234 | 234.34K | PROC |
  8. | 1233 | 2230S | DRG |
  9. | 1233 | 996k | DRG |
  10. | 1233 | 55239 | PROC |
  11. +--------------+--------------+-------------+
  12.  
  13. table:example
  14. +--------------+-------------+-------------+-----------+
  15. | id_nr | subtype | ipc_code | asc_code |
  16. +------------------------------------------------------+
  17. | 1445 | DRG | | 40D1343 |
  18. | 1445 | PROC | 23423asas | |
  19. | 1234 | PROC | 234.34K | |
  20. | 1233 | DRG | | 2230S |
  21. | 1233 | DRG | | 996k |
  22. | 1233 | PROC | 55239 | |
  23. +--------------+-------------+-------------+-----------+
  24.  
  25. select id_nr, subtype,
  26. (case when subtype = 'PROC' then code end) as ipc_code,
  27. (case when subtype = 'DRG' then code end) as asc_code
  28. from t;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement