Advertisement
Guest User

assienment 3

a guest
Feb 22nd, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. create database Durjoy3
  2.  
  3.  
  4. create table Course(
  5. CID nvarchar(10) not null primary key,
  6. CName nvarchar(20) not null,
  7. Semester nvarchar(20) not null
  8. )
  9.  
  10. create table Student(
  11. SID nvarchar(15) not null primary key,
  12. SName nvarchar(30) not null,
  13. CGPA float not null,
  14. Age int not null
  15. )
  16.  
  17. create table Takes(
  18. SID nvarchar(15) foreign key references Student(SID),
  19. CID nvarchar(10) foreign key references Course(CID)
  20. )
  21.  
  22. select * from Course
  23. select * from Student
  24. select * from Takes
  25.  
  26. insert into Course values('CSE101','DATA','SPRING 2020')
  27. insert into Course values('CSE102','MATH','SPRING 2020')
  28. insert into Course values('CSE103','ART OF LIVING','SPRING 2020')
  29. insert into Course values('CSE104','COMPUTER-I','SPRING 2020')
  30. insert into Course values('CSE105','COMPUTER-II','SPRING 2020')
  31. insert into Course values('CSE106','DATA SCIENCE','SPRING 2020')
  32.  
  33. insert into Student values('181-15-11017','Alimozzaman Durjoy',3.6,23)
  34. insert into Student values('181-15-11018','Azizul Islam',3.46,17)
  35. insert into Student values('181-15-11019','Didar',3.00,19)
  36. insert into Student values('181-15-11020','Anika Hossain',3.89,22)
  37. insert into Student values('181-15-11021','Md Hasan',3.3,24)
  38. insert into Student values('181-15-11022','Asaduzzaman',3.8,19)
  39.  
  40. insert into Takes values('181-15-11017','CSE101')
  41. insert into Takes values('181-15-11018','CSE105')
  42. insert into Takes values('181-15-11019','CSE102')
  43. insert into Takes values('181-15-11020','CSE101')
  44. insert into Takes values('181-15-11021','CSE101')
  45. insert into Takes values('181-15-11022','CSE106')
  46.  
  47. #1
  48.  
  49. alter table student add Email nvarchar(50) check(len(Email)>(10))
  50.  
  51. #2
  52. select count(SID) as NumberOfStudent from Student where CGPA>3.5 and age>18
  53.  
  54. #3
  55. select SName,CGPA from Student where CGPA > (select CGPA from Student where SName= 'Azizul Islam')
  56.  
  57. #4
  58. select avg(Age) as Avarage_age from Student where SName like 'A%'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement