0% found this document useful (0 votes)
10 views2 pages

SQL Queries for Student Data Analysis

The document contains a series of SQL queries related to a student table named 'STU'. It includes requests to display student details, filter by age and department, and count students by gender. The queries also focus on specific conditions such as names starting with 'A' and containing 'n', as well as handling NULL values in the department field.

Uploaded by

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

SQL Queries for Student Data Analysis

The document contains a series of SQL queries related to a student table named 'STU'. It includes requests to display student details, filter by age and department, and count students by gender. The queries also focus on specific conditions such as names starting with 'A' and containing 'n', as well as handling NULL values in the department field.

Uploaded by

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

SQL BOARD WORKSHEET

Table : Stu

i. Write a Query to display all the details of the student from the above table 'STU'.
ii. Write a Query to list name of the students whose ages are between 18 to 20.
iii. Write a Query to display the name of the students whose name is
starting with 'A'.
iv. Write a Query to select distinct Department from STU table.

i. Write a query to display Rollno, Name and Department of the students from STU
table.
ii. Write a query to Display Name of all students whose dept Contains NULL.
iii. Write a Query to list name of female students in Hindi Department.
iv. Write a query to list the names of those students whose name have second alphabet
'n' in their names.

i. Write a query to show all information about students of History department.


ii. Write a query to display Name, DOB and fees of the students from STU table.
iii. Write a Query to list name of the students whose ages are between 20 to 25.
iv. Write a query to count the number of male and female students.
i. Write a query to display the names and age in descending order of the age.
ii. Write a query to display all information about students of Computer department.
iii. Write a query to display names of female students in Hindi department
iv. Write a query to count number of students in each department.

i. Write a query to display all information about students of Computer department.


ii. Write a Query to list name of the students whose ages are between 20 to 25.
iii. Write a query to Display Name of all students whose department Contains NULL.
iv. Write a Query to display all the details of the student from the above table 'STU'.

Common questions

Powered by AI

To find students with 'n' as the second letter in their names, the query uses the LIKE operator: SELECT Name FROM STU WHERE Name LIKE '_n%'. This pattern matches names where the second character is 'n', '_' matches any first character, and '%' matches the following sequence .

To count male and female students in the STU table, group by gender and use the COUNT() function: SELECT Gender, COUNT(*) FROM STU GROUP BY Gender. This groups rows by Gender and counts the number of students in each group, effectively separating male and female student counts .

To find students aged between 20 and 25, you would use the following SQL statement: SELECT Name FROM STU WHERE Age BETWEEN 20 AND 25. This sets an age range filter to retrieve the list of student names .

To display names and ages in descending order by age, the query is: SELECT Name, Age FROM STU ORDER BY Age DESC. This sorts the results by Age in descending order .

To retrieve names where the department is NULL, use the query: SELECT Name FROM STU WHERE Department IS NULL. This filters the results to show only those students whose Department field contains NULL values .

To display female students in the Hindi Department, the query needs to filter on gender and department: SELECT Name FROM STU WHERE Gender = 'Female' AND Department = 'Hindi'. This SQL command selects the names of all students whose Gender is Female and who are enrolled in the Hindi Department .

To find distinct departments in the STU table, you use the SELECT DISTINCT statement: SELECT DISTINCT Department FROM STU. This returns a list of unique department values without duplicates .

To show all information about History department students, use: SELECT * FROM STU WHERE Department = 'History'. This selects all columns where the Department is History, thereby returning complete student records .

To list all students whose names start with 'A', you can use the SQL SELECT statement with the LIKE operator. The query would be: SELECT * FROM STU WHERE Name LIKE 'A%'. This retrieves all rows from the STU table where the Name column begins with 'A' .

To display details of students from the Computer department, the SQL query is: SELECT * FROM STU WHERE Department = 'Computer'. This selects all columns for rows where the Department is specified as Computer, thus providing full details .

You might also like