fork download
  1.  
  2. database veere_db;
  3.  
  4. --creating table
  5. create table employee
  6. (
  7. emp_nm varchar(255),
  8. emp_dept varchar(255),
  9. salary int
  10. );
  11.  
  12. --inserting into table, teradata style
  13. insert into employee
  14. values ('&Mary&beth','Admin',5000);
  15. insert into employee
  16. values ('&raj&bhat','HR',10000);
  17. insert into employee
  18. values ('&Veena&Kumar','HR',15000);
  19. insert into employee
  20. values ('Sheela','Admin',5000);
  21. insert into employee
  22. values ('&Bibin&Joseph','Academy',20000);
  23. insert into employee
  24. values ('&royvivin','Academy',16000);
  25. insert into employee
  26. values ('&Arun&Kumar','HR',20000);
  27. insert into employee
  28. values ('Varun&Kumar','Academy',10000);
  29.  
  30. --veryfying table population
  31. select *
  32. from employee;
  33.  
  34.  
  35. --useful Hint
  36. select
  37. substr(emp_nm, (position('&' in emp_nm)+1)) as ename,
  38. trim(trailing '&' from substr(ename,1,position('&' in ename))) as fname,
  39. substr(ename,(position('&' in ename)+1)) as lname,
  40. emp_dept,
  41. salary,
  42. rank() over (partition by emp_dept order by salary desc) as ranka
  43. from employee
  44. qualify ranka=2
  45.  
  46.  
  47. --Corrections Needed
  48. /*
  49. Use 'Case' where last name is missing to avoid getting first name in last name column.
  50. Work on Selective Output, remove ename and ranka from output.
  51. */
  52.  
  53.  
  54.  
  55.  
  56.  
Success #stdin #stdout #stderr 0.01s 5516KB
stdin
Standard input is empty
stdout
&Mary&beth|Admin|5000
&raj&bhat|HR|10000
&Veena&Kumar|HR|15000
Sheela|Admin|5000
&Bibin&Joseph|Academy|20000
&royvivin|Academy|16000
&Arun&Kumar|HR|20000
Varun&Kumar|Academy|10000
stderr
Error: near line 2: near "database": syntax error
Error: near line 36: near "'&'": syntax error