Achu M.
asked 11/11/20Deptmaster (deptid,deptname, dlocation), coursemaster (deptid, courseid,coursename), strengthmaster (deptid, courseid, maxstudentallow), studentdetails (deptid, courseid, studno, studname);
1) display the department and course where maximum students registered
2) select name, department and course of student whose names begin with 'A'
3) display department name of student having student number 1
2 Answers By Expert Tutors
Justin F. answered 11/12/20
Master Python and SQL programmer
Please schedule a lesson for Q2 and Q3!

Amedeo F. answered 11/16/20
SQL Server and Data Analytics Developer with 20 years experience
Explanation for the answer provided for Question #1 - display the department and course where maximum students registered
The question is asking for two fields to be displayed in the resultset - Department (table = deptmaster, field name = deptname) and Course (table = coursemaster, fieldname = coursename). However, the requirement for the Course field is to display the course with the max number of registered units (table = strenthmaster).
This data is being pulled from 3 tables - hence the joins to three tables. The WHERE statement (WHERE s.maxstudentallow = MAX(SELECT maxstudentallow FROM strengthmaster) is how the resultset is filtered to only list the course with the max number of students.
Responses for your other two questions are:
2) select name, department and course of student whose names begin with 'A'
SELECT sd.studname, d.deptname, c.coursename
FROM deptmaster d
INNER JOIN coursemaster c
ON d.deptid = c.deptid
INNER JOIN studentdetails sd
ON d.deptid = sd.deptid AND c.courseid = sd.courseid
WHERE SUBSTRING(studname,1,1) = 'A'
Explanation - Substring function arguments (Field Name, Start Position, Number of Characters to return). This will return Students in which the first character of the "studname" field starts with "A".
3) display department name of student having student number 1
SELECT d.deptname
INNER JOIN studentdetails sd
ON d.deptid = sd.deptid
WHERE studno = '1'
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Achu M.
Thank you sir for valuable information thank you so much11/16/20