Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. --lab manual 4
  2.  
  3. --exercise 1
  4. -- 1
  5. Select(rPrice * 0.1) as Maintenance from Property
  6. --2
  7. Select (sq_ft * 4000) as rental_price from Commercial where sq_ft > 100
  8. --3
  9. Select ((40 * 1500) + commision) as salary from Employee
  10. --4
  11.  
  12. --exercise 2
  13.  
  14. --a
  15. --number of residential
  16. SELECT COUNT(property_code) from Residential
  17. SELECT COUNT(comm_property_code) from Commercial
  18. SELECT COUNT(code) from Property
  19.  
  20. --b
  21. SELECT AVG(rPrice) as avg_rentalPrice from Property
  22. --c
  23. SELECT MAX(rPrice) from Property
  24. --d
  25. SELECT MIN(rPrice) from Property
  26. --e
  27. SELECT SUM(rPrice) from Property
  28.  
  29. --exercise 3
  30. --1
  31. SELECT COUNT(parish) from Property GROUP BY parish
  32.  
  33. --2
  34. SELECT COUNT(code) from Property GROUP BY parish
  35. --3
  36. SELECT SUM(rPrice) from Property GROUP BY parish
  37.  
  38. --SELECT GETDATE()
  39. --1
  40. insert into Employee (empID,fname,lname,gender,date_hired,dob,parish,commision,position,email) values
  41. (2001,'jay','carter','m','2004-08-12','1980-12-12','St.Elizabeth',0.2,'Clerk','j.carter@gmail.com');
  42.  
  43. insert into Employee (empID,fname,lname,gender,date_hired,dob,parish,commision,position,email) values
  44. (2002,'Trish','Tardair','f','2009-07-08','1990-09-12','St.Andrew',0.2,'Clerk','t.tardair@gmail.com'),
  45. (2003,'Cameron','Khalid','m','2012-01-09','1985-01-15','Manchester',0.2,'Clerk','c.kh@gmail.com'),
  46. (2004,'Tammi','Bell','f','2003-11-22','1991-10-05','St.Catherine',0.2,'Clerk','t.bell@gmail.com'),
  47. (2005,'Niklaus','Cordair','m','2017-10-05','1992-01-02','St.James',0.2,'Clerk','n.cordair@gmail.com');
  48.  
  49. insert into Employee (empID,fname,lname,gender,date_hired,dob,parish,commision,position,email) values
  50. (2006,'walter','white','m','2017-09-12','1998-02-04','St.Andrew',0.2,'Clerk','w.white@gmail.com');
  51. --2
  52. SELECT * from Employee where DateDiff(year,dob,GETDATE()) > 21
  53. --3
  54. insert into Employee (empID,fname,lname,gender,date_hired,dob,parish,commision,position,email) values
  55. (2007,'Tisha','Aneque','f','2017-09-11','2001-02-04','St.Andrew',0.2,'Intern','t.neque@gmail.com');
  56.  
  57. SELECT * from Employee where DateDiff(year,dob,GETDATE()) > 12 AND(DateDiff(year,dob,GETDATE()) < 18)
  58.  
  59. --4
  60. insert into Employee (empID,fname,lname,gender,date_hired,dob,parish,commision,position,email) values
  61. (2008,'Trina','Migo','f','2017-08-13','2001-02-28','Clarendon',0.2,'Intern','third_migo@gmail.com');
  62.  
  63. SELECT(DateDiff(year,dob,GETDATE())) as age ,fname,lname from EMPLOYEE where Month(dob) = 2 AND (DAY(dob) = 28)
  64. --5
  65. Select * from Employee where DateDiff(year,date_hired,GETDATE()) > 10
  66.  
  67. insert into Employee (empID,fname,lname,gender,date_hired,dob,parish,commision,position,email) values
  68. (2009,'Kelly','Angelo','f','2007-05-28','2000-10-06','Manchester',0.2,'Intern','k.ange@gmail.com');
  69.  
  70. select fname,lname from Employee where DateDiff(year,DateADD(month,5,date_hired),GETDATE()) > 10
  71.  
  72. SELECT * from Employee where DateDiff(year,dob,'2017-09-30') >= 18 AND (DateDiff(year,date_hired,GETDATE()) > 10)
  73.  
  74. SELECT ownersID, prop_code, DateDiff(month,date_sold,GETDATE()) from Owns
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement