1Write an sql statement that creates a query
SELECT <field(s) name>,
FROM <table name>,
WHERE <search-condition>,
2Write an Sql Statement that displaye the statement by order
SELECT <field(s) name>,
FROM <table name> ,
ORDER BY <search-condition> ,
3Write an Sql Statement to count the number of the <field(s) name> grouped by another <field(s) name2>
SELECT COUNT(<field(s) name>) , <field(s) name2>
FROM <table name> ,
GROUP BY <field(s) name2>
4Write an Sql Statement on on a table name that diplays a <field name> that selects the same a specific <variable> from two different <table name>
SELECT <field(s) name >
FROM table name,
WHERE <field(s) name2> = 'variable1' AND <field(s) name3> = 'variable2>;
5Write an Sql Statement that displays the <field name> starting with it's first letter <CHAR>
SELECT StudentName
FROM STUDENT
WHERE StudentName LIKE '<CHAR>%;
6Write an Sql Statement that calculates the total of a <field name> from <table name>
SELECT SUM (<field name>)
FROM <table name>;
7Write an Sql Statement that calculates the average <field name> of the <table name>
SELECT AVG (<field name>)
FROM <table name>;
8What SQL statement is used to create a new database named "Name"?
CREATE DATABASE Name
9 How do you create a table named "Student" with columns ID, Name, Address, Number, Birthday, and set ID as the primary key
CREATE TABLE Student (ID INT,
Name VARCHAR(25),
Address TEXT,
Number INT,
Birthday DATE,
PRIMARY KEY (ID));
10What SQL command is used to add a primary key constraint to an existing table "Student" with the column "ID"
ALTER TABLE Student ADD PRIMARY KEY (ID);
11How can you add a composite primary key consisting of columns "ID" and "ID2" to the "Student" table?
ALTER TABLE Student ADD PRIMARY KEY (ID, ID2);
12 What SQL statement is used to add a foreign key constraint to the "Student" table, referencing the "ID" column from the "Grades" table?
ALTER TABLE Student ADD FOREIGN KEY (ID) REFERENCES
Grades(ID);
13How do you add a new column named "Class" with data type VARCHAR(2) to the "Student" table?
ALTER TABLE Student ADD COLUMN Class VARCHAR(2)
14What SQL command is used to remove the "Class" column from the "Student" table?
ALTER TABLE Student DROP Class
15How would you insert a new row into the "Student" table with values for columns ID, Name, Address, Number, and Birthday?
INSERT INTO Student (ID, Name, Birthday) VALUES(2,
“Asim”, 2/2/2)
16How would you insert a new row into the "Student" table with the following values:
ID = 1,
Name = "Ali,"
Address = "ABC,"
Number = 123, and
Birthday = January 1, 1 AD?
INSERT INTO Student VALUES(1, “Ali”, “ABC”, 123,
1/1/1);
17What SQL statement is used to delete a record from the "Student" table where the ID is equal to 2?
DELETE FROM Student WHERE ID = 2
18How can you update the "Number" column in the "Student" table to set it to 456 for the record with ID equal to 2?
UPDATE Student SET Number = 456 WHERE ID = 2;
19What SQL query would you use to retrieve the columns ID, Birthday, and Name from the "Student" table?
SELECT ID, Birthday, Name FROM Student
20How do you select records from the "Student" table where the "Name" column starts with "123"?
SELECT Name FROM Student WHERE Name LIKE “123*”
21 What SQL query is used to retrieve the "Name" and "Rating" columns from the "Movie" table by joining it with the "Timings" table on the "ID" column and filtering where "Movie.Name" is "Monster"?
SELECT Name, Rating FROM Movie INNER JOIN Timings ON
Movie.ID = Timings.ID WHERE Movie.Name = “Monster”;
22How would you retrieve the columns ID and Birthday from the "Student" table, order the results by the "Name" column in ascending or descending order, and then group the results by the "Class" column?
SELECT ID, Birthday FROM Student ORDER BY Name
ASC/DESC GROUP BY Class;
23What SQL query can you use to count the number of records in the "Student" table based on the "Name" column?
SELECT COUNT(Name) FROM Student;
24How do you calculate the sum of the "ID" column values in the "Student" table using SQL?
SELECT SUM(ID) FROM Student;
25What SQL statement is used to calculate the average value of the "Percentage" column in the "Student" table?
SELECT AVG(Percentage) FROM Student;