Podcast
Questions and Answers
What is the primary key in the 'student' table?
What is the primary key in the 'student' table?
- studid (correct)
- student_id
- name
- marks
Which command would you use to insert a new student into the 'student' table?
Which command would you use to insert a new student into the 'student' table?
- add into student values(6, 'Anita', 75);
- insert student(6, 'Anita', 75);
- insert into student values(6, 'Anita', 75); (correct)
- insert student values(6, 'Anita', 75);
How would you retrieve students with marks greater than or equal to 80?
How would you retrieve students with marks greater than or equal to 80?
- select * from student where marks > 80;
- select student from marks >= 80;
- select * where marks >= 80 from student;
- select * from student where marks >= 80; (correct)
What is the purpose of the 'group by' clause in SQL?
What is the purpose of the 'group by' clause in SQL?
Which SQL command correctly returns the total number of customers grouped by country?
Which SQL command correctly returns the total number of customers grouped by country?
How do you sort the student records by name in descending order?
How do you sort the student records by name in descending order?
What does the following SQL command do: 'Select UPPER(pname) as ‘patient name’, YEAR(admitdate) as ‘admit year’ From hospital;'?
What does the following SQL command do: 'Select UPPER(pname) as ‘patient name’, YEAR(admitdate) as ‘admit year’ From hospital;'?
Which SQL command will correctly fetch the first four letters of patient names admitted before May?
Which SQL command will correctly fetch the first four letters of patient names admitted before May?
What command is used to create a new database in SQL?
What command is used to create a new database in SQL?
Which SQL command will display the names of coaches earning more than 3500 in ascending order of their names?
Which SQL command will display the names of coaches earning more than 3500 in ascending order of their names?
Flashcards
Creating a student table
Creating a student table
SQL statement to define a table named 'student' with columns for student ID, name, and marks. Student ID is the primary key.
Inserting student data
Inserting student data
SQL statement to add new rows (records) with student information into an existing 'student' table.
Querying students with marks > 80
Querying students with marks > 80
SQL statement to retrieve details of students who have scored more than 80 marks in the 'student' table.
Counting customers per country
Counting customers per country
Signup and view all the flashcards
Ordering by marks (desc)
Ordering by marks (desc)
Signup and view all the flashcards
Displaying patient names with admit year
Displaying patient names with admit year
Signup and view all the flashcards
Displaying first four letters and length
Displaying first four letters and length
Signup and view all the flashcards
Creating a database
Creating a database
Signup and view all the flashcards
Creating table
Creating table
Signup and view all the flashcards
Insert data into table
Insert data into table
Signup and view all the flashcards
Study Notes
Practical-1
- Problem: Create a
student
table withstudid
(primary key),name
, andmarks
. - Solution: SQL code to create the table.
Practical-2
- Problem: Insert student details into the
student
table. - Solution: SQL insert statements for various students (e.g., Sanjay, Surendra, Jamil, Rahul, Prakash), providing their
studid
,name
, andmarks
.
Practical-3
- Problem: Retrieve student details with marks above 80.
- Solution: SQL query to filter students where
marks
are greater than or equal to 80.
Practical-5
- Problem: Calculate the total number of customers from each country.
- Solution: SQL query to count customers by
country
.
Practical-6
- Problem: Order student records (studid, marks) by
name
in descending order. - Solution: SQL query to sort student records by
name
in descending order.
Practical-7 (Min, Max, Sum, Average)
- Problem: Find the minimum, maximum, sum, and average of marks.
- Solution: SQL query using
min()
,max()
,sum()
, andavg()
functions on themarks
column.
Practical-8
- Problem: Display patient names in uppercase and admission year.
- Solution: SQL query using
UPPER()
andYEAR()
functions onpname
andadmitdate
attributes, respectively.
Practical-9
- Problem: Display first four letters of patient names and the name length, for patients admitted before May.
- Solution: SQL query using
LEFT()
andLENGTH()
functions.
Practical-10 (Creating and Inserting into a Table)
- Problem: Create a database (e.g.,
abc
) and a table within it. Insert data into the table (e.g., Coach'scoachname
,age
,sports
,salary
,sex
details) - Solution: SQL commands to create a database,
club
table with fields (coach_id, coachname, age, sports, salary, sex). Insert data for various coach records. - Additional Problem (Practical-10): Display coaches playing basketball
- Solution: Select coach names where sports is "Basketball".
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers various practical exercises related to SQL, including creating a student table, inserting records, and retrieving data based on conditions. You'll also learn to perform aggregate functions like counting, finding min/max, and ordering results. Test your SQL skills with hands-on examples and queries.