0% found this document useful (0 votes)
44 views4 pages

Student Database Query Examples

The document contains a series of SQL queries related to a 'student' database. These queries include selecting all students, filtering by age and course, calculating averages and sums of marks, counting students by city and gender, and retrieving specific details based on conditions. Overall, the queries aim to analyze student data based on various criteria.

Uploaded by

mananranpariya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views4 pages

Student Database Query Examples

The document contains a series of SQL queries related to a 'student' database. These queries include selecting all students, filtering by age and course, calculating averages and sums of marks, counting students by city and gender, and retrieving specific details based on conditions. Overall, the queries aim to analyze student data based on various criteria.

Uploaded by

mananranpariya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1)Query:- SELECT * FROM `student`;

2)Query:- SELECT * FROM `student` WHERE age>21;

3)Query:- SELECT * FROM `student` WHERE course='science';

4)Query:- SELECT AVG(marks) from student;

5)Query:- SELECT Course,COUNT(Course) as student_count FROM student


GROUP BY Course;

6)Query:- SELECT name FROM student WHERE Marks=(SELECT MAX(Marks)


FROM student);
7)Query:- SELECT * FROM `student` WHERE gender='female';

8)Query:- SELECT SUM(Marks) FROM student WHERE City='vadodara';

9)Query:- SELECT name,marks FROM student ORDER BY Marks desc;

10)Query:- SELECT COUNT(*) AS count_surat FROM student WHERE


City='surat';

11)Query:- SELECT Name,Marks FROM student WHERE Marks>80;


12)Query:- SELECT name,age FROM student WHERE age=(SELECT min(age)
FROM student);

13)Query:- SELECT COUNT(name) FROM student;

14)Query:- SELECT name,Marks FROM student ORDER BY Course asc;

15)Query:- SELECT course,avg(marks) as marks_count FROM student GROUP


By course;

16)Query:- SELECT * FROM `student` WHERE city='ahmedabad' or City='surat';


17)Query:- SELECT name,marks FROM `student` WHERE Marks BETWEEN 80
and 90;

18)Query:- SELECT gender,count(gender) AS count_gender from student group


by gender;

Common questions

Powered by AI

The use of a subquery, like 'SELECT name, age FROM student WHERE age=(SELECT MIN(age) FROM student);', allows the identification of specific data points (e.g., name) associated with the minimum age, which cannot be directly achieved with a simple aggregation function alone . It selects rows matching the minimal condition, aligning broader queries with more contextually relevant information than executing two separate queries.

The query 'SELECT * FROM student WHERE city='ahmedabad' OR City='surat';' selects students from either Ahmedabad or Surat. This combined filtering enables localized demographic analysis, vital in resource allocation or educational policy development .

Use the query 'SELECT SUM(Marks) FROM student WHERE City='vadodara';' to sum the marks of students from Vadodara. The WHERE clause restricts the selection to rows from the specified city, enabling focused aggregation .

To find the student with the highest marks, use the query 'SELECT name FROM student WHERE Marks=(SELECT MAX(Marks) FROM student);'. This subquery strategy identifies the maximum mark and filters the student(s) who have this score .

The query 'SELECT Course, COUNT(Course) as student_count FROM student GROUP BY Course;' groups students by their courses and counts the students in each, effectively detailing course populations .

The query 'SELECT * FROM student WHERE gender='female';' isolates female students by filtering on the gender column. This practice helps target specific demographic information or analysis within databases .

The query 'SELECT Course, AVG(marks) as marks_average FROM student GROUP BY Course;' allows you to compute the average marks for students in each course. It groups the entries by the course column and calculates the average marks for each group .

The query 'SELECT name, marks FROM student WHERE Marks BETWEEN 80 AND 90;' fetches students whose marks fall within 80 to 90. This targeted filtering supports focused analytics in performance band assessments, crucial for benchmarking or support interventions .

By using 'SELECT gender, COUNT(gender) AS count_gender FROM student GROUP BY gender;', one can comprehend gender distribution among students, facilitating studies on gender parity in education or potential biases in enrollment trends .

To achieve this, you can use the query 'SELECT name, marks FROM student WHERE Marks > 80 ORDER BY Marks DESC;'. This query filters students who scored above 80 marks and orders the results from highest to lowest marks .

You might also like