Write queries for the following.Student_Result (Roll_No, Enrollment_No , Name, Div, Branch, Mentor , DBMS , DS ,JAVA_II , MATHS_II , FEE)(1) Display branchwise count of student in descending order.(2) Display the roll no, name and mentor of student who got less than 9 marks in anysubject.(3) Display the branchwise maximum total marks of all subject
Question
Write queries for the following.Student_Result (Roll_No, Enrollment_No , Name, Div, Branch, Mentor , DBMS , DS ,JAVA_II , MATHS_II , FEE)(1) Display branchwise count of student in descending order.(2) Display the roll no, name and mentor of student who got less than 9 marks in anysubject.(3) Display the branchwise maximum total marks of all subject
Solution
- To display branchwise count of students in descending order, you can use the COUNT() function and GROUP BY statement. The query would look like this:
SELECT Branch, COUNT(*) AS 'Number of Students'
FROM Student_Result
GROUP BY Branch
ORDER BY COUNT(*) DESC;
- To display the roll no, name, and mentor of students who got less than 9 marks in any subject, you can use the WHERE clause to filter out the students. The query would look like this:
SELECT Roll_No, Name, Mentor
FROM Student_Result
WHERE DBMS < 9 OR DS < 9 OR JAVA_II < 9 OR MATHS_II < 9;
- To display the branchwise maximum total marks of all subjects, you can use the MAX() function and GROUP BY statement. The query would look like this:
SELECT Branch, MAX(DBMS + DS + JAVA_II + MATHS_II) AS 'Maximum Total Marks'
FROM Student_Result
GROUP BY Branch;
Similar Questions
Write a query to display the student qualification(squal) and the total number of students based on their qualifications. Give an alias name as ‘totalStud’. Display only the squal having the totalStud count less than 8. Display the records sorted in ascending order based on squal.
Consider following schema and write SQL for given statements.Student (RollNo, Name, DeptCode, City)Department (DeptCode, DeptName)Result (RollNo, Semester, SPI)1. List out the RollNo, Name along with SPI of Student.2. Display student name who got highest SPI in semester 1.3. Display the list of students whose DeptCode is 5, 6,7,10
Consider these following tables and only solve the query. Tables: 1) student: s_no (primary key), student_name, course_no (foreign key), age 2) courser-course-no (primary key), course-name. Query: Display all the student name, course name and also age of the students, whose age is between 23 to 27 and course having 'BCA'. Find out the students whose age is maximum.
Write a query to display the coursename of the courses having the coursefees above average fees of all the courses. Display the records sorted in ascending order based on coursename.Note:1. Display only the coursename of the courses having the coursefees above average fees of all the courses.2. Order by is mandatory.Sample Output:
For the following tables and a query:Student (studentId, studentName, address) Result (studentId, subjectId, score) Subject (subjectId, subjectName) Which code snippet will display students with the highest 'SQL Basics' test scores?SELECT TOP 1 WITH TIES s.*FROM STUDENT s JOIN RESULT r ON s.studentId = r.studentIdWHERE r.subjectId =(SELECT ss.subjectId FROM dbo.Subject ssWHERE ss.subjectName = 'SQL Basics');SELECT TOP 1 WITH TIES s.*FROM STUDENT s JOIN RESULT r ON s.studentId = r.studentIdWHERE r.subjectName = 'SQL Basics'ORDER BY score DESC;SELECT TOP 1 WITH TIES s.*FROM STUDENT s JOIN RESULT r ON s.studentId = r.studentIdWHERE r.subjectId = 'SQL Basics'ORDER BY score DESC;SELECT TOP 1 WITH TIES s.*FROM STUDENT s JOIN RESULT r ON s.studentId = r.studentIdWHERE r.subjectId =(SELECT ss.subjectId FROM dbo.Subject ssWHERE ss.subjectName = 'SQL Basics')ORDER BY score DESC;
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.