Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. Zadanie 1
  2. select ename,
  3. CASE deptno
  4. when 20 then 'Sprzedawca'
  5. when 30 then 'cos tam'
  6. else 'Pozostali'
  7. end
  8. from emp
  9.  
  10.  
  11. Zadanie 2
  12.  
  13. select ename,
  14. (CASE
  15. when DEPTNO =30 then 'Sprzedarz'
  16. when DEPTNO = 10 and COMM is null or COMM=0 then 'księgowość bez prowizji'
  17. when DEPTNO = 10 and COMM is not null and COMM>0 then 'księgowość Z prowizji'
  18. else 'Pozostali'
  19. end) as 'Dodatkowa kolumna'
  20. from emp
  21.  
  22. Zadanie 3
  23. CREATE TRIGGER tworzenie
  24. ON DATABASE
  25. FOR CREATE_TABLE
  26. AS BEGIN
  27. ROLLBACK
  28. PRINT 'no nie da sie'
  29. END
  30.  
  31. zadanie 4
  32.  
  33. create function srednia (@deptno int)
  34. returns decimal
  35. as begin
  36. declare @srednia decimal
  37. select @srednia=AVG(sal) from emp where DEPTNO=@deptno
  38. return @srednia
  39. end
  40. select * from emp where sal < dbo.srednia(10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement