Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
41 views3 pages

Single Rown Function Revision Practice

The document provides a comprehensive guide on SQL single row functions relevant for Class 12th IP, including the creation of a 'Nobel' table and various SQL queries to manipulate and retrieve data. It covers tasks such as inserting records, displaying specific winners based on criteria, and modifying the table structure. The document includes example SQL commands for each task, demonstrating practical applications of SQL functions.

Uploaded by

Manvi Jain
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)
41 views3 pages

Single Rown Function Revision Practice

The document provides a comprehensive guide on SQL single row functions relevant for Class 12th IP, including the creation of a 'Nobel' table and various SQL queries to manipulate and retrieve data. It covers tasks such as inserting records, displaying specific winners based on criteria, and modifying the table structure. The document includes example SQL commands for each task, demonstrating practical applications of SQL functions.

Uploaded by

Manvi Jain
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
You are on page 1/ 3

Class 12th IP

SQL - Single Row Function Full Revision with CBSE Paper 2023
Lovejeet Arora
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

The table contains the following data:

Winner_id Year Subject Winner Country Category


1001 1970 Physics Hannes Alfven Sweden Scientist
1002 1970 Physiology Bernard Katz NULL Scientist
1003 1970 Literature Aleksandr Solzhenitsyn Russia Linguist
1004 1971 Chemistry Gerhard Herzberg Germany Scientist
1005 1978 Peace Menachem Begin Israel Prime Minister
1006 1987 Economics Robert Solow USA Economist
1007 1994 Literature Kenzaburo Oe Japan Linguist
1. Create the table 'Nobel'.
2. Set Primary Key to an appropriate column.
3. Insert any 2 or 3 records.
4. Display the names of Nobel Prize winners in 'Literature' for the year 1970.
5. Display the subject and category of winners whose country is not known.
6. Display the details of all Nobel Prize winners who were Scientists.
7. Display the names of Nobel Prize winners whose names contain the substring 'berg'.
8. Display the last two characters of all Winners who are Scientists.
9. Display the country name of those who won the Nobel Prize after 1971.
10. Display the names of Nobel Prize winners in lowercase and the length of their names.
11. Display the Winner names whose name length is 12 characters.
12. Display the first 4 characters of each Nobel Prize winner's name.
13. Display the details of Nobel Prize winners whose winning year is between 1970 and 1980.
14. Delete the record of the Nobel Prize winner with the Winner_id 1003.
15. Add a new column Age to the Nobel table with an appropriate data type.
16. Display the first 3 characters of the Nobel Prize winner's name.
17. Display the names of winners who won the Nobel Prize in Physics in the year 1970.
18. Display the names of those who won the Nobel Prize from Sweden and the USA.
19. Display the last 3 characters of the winners' country names for those who won the prize after
1975.

Lovejeet Arora
Class 12th IP
SQL - Single Row Function Full Revision with CBSE Paper 2023
Lovejeet Arora
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Answers
1. CREATE TABLE NOBEL (
Winner_id INT PRIMARY KEY,
Year INT,
Subject VARCHAR(50),
Winner VARCHAR(100),
Country VARCHAR(50),
Category VARCHAR(50)
);
3. INSERT INTO NOBEL (Winner_id, Year, Subject, Winner, Country, Category) VALUES
(1001, 1970, 'Physics', 'Hannes Alfven', 'Sweden', 'Scientist'),
(1002, 1970, 'Physiology', 'Bernard Katz', NULL, 'Scientist'),
(1003, 1970, 'Literature', 'Aleksandr Solzhenitsyn', 'Russia', 'Linguist'),
(1004, 1971, 'Chemistry', 'Gerhard Herzberg', 'Germany', 'Scientist'),
(1005, 1978, 'Peace', 'Menachem Begin', 'Israel', 'Prime Minister'),
(1006, 1987, 'Economics', 'Robert Solow', 'USA', 'Economist'),
(1007, 1994, 'Literature', 'Kenzaburo Oe', 'Japan', 'Linguist');
4. Display the names of Nobel Prize winners in 'Literature' for the year 1970.
SELECT Winner FROM Nobel WHERE Subject = 'Literature' AND Year = 1970;
5. Display the subject and category of winners whose country is not known.
SELECT Subject, Category FROM Nobel WHERE Country IS NULL;
6. Display the details of all Nobel Prize winners who were Scientists.
SELECT * FROM Nobel WHERE Category = 'Scientist';
7. Display the names of Nobel Prize winners whose names contain the substring 'berg'.
SELECT Winner FROM Nobel WHERE Winner LIKE '%berg%';
OR
SELECT Winner FROM Nobel WHERE INSTR(Winner, 'berg') != 0;
8.Display the last two characters of all Winners who are Scientists.
SELECT SUBSTR(Winner, -2) FROM Nobel WHERE Category = 'Scientist';
9.Display the country name of those who won the Nobel Prize after 1971.
SELECT Country FROM Nobel WHERE Year > 1971;
10.Display the names of Nobel Prize winners in lowercase and the length of their names.
SELECT LCASE(Winner), LENGTH(Winner) FROM Nobel;
11.Display the Winner names whose name length is 12 characters.
SELECT Winner FROM Nobel WHERE LENGTH(Winner) = 12;
OR
SELECT Winner FROM Nobel WHERE Winner LIKE '____________';
12. Display the first 4 characters of each Nobel Prize winner's name.
SELECT SUBSTR(Winner, 1, 4) FROM Nobel;
OR
SELECT LEFT(Winner,4) FROM Nobel;
13.Display the details of Nobel Prize winners whose winning year is between 1970 and 1980.

Lovejeet Arora
Class 12th IP
SQL - Single Row Function Full Revision with CBSE Paper 2023
Lovejeet Arora
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

SELECT * FROM Nobel WHERE Year BETWEEN 1970 AND 1980;


OR
SELECT * FROM Nobel WHERE year>=1970 AND year <=1980;
14.Delete the record of the Nobel Prize winner with the Winner_id 1003.
DELETE FROM Nobel WHERE Winner_id = 1003;
15.Add a new column Age to the Nobel table with an appropriate data type.
ALTER TABLE Nobel ADD COLUMN Age INT;
OR
ALTER TABLE Nobel ADD Age INT;
16.Display the first 3 characters of the Nobel Prize winner's name.
SELECT LEFT(Winner, 3) FROM Nobel;
OR
SELECT SUBSTR(Winner, 1,3) FROM Nobel;
OR
SELECT SUBSTRING(Winner, 1,3) FROM Nobel;
OR
SELECT MID(Winner, 1,3) FROM Nobel;
17.Display the names of winners who won the Nobel Prize in Physics in the year 1970.
SELECT Winner FROM Nobel WHERE Subject = 'Physics' AND Year = 1970;
18.Display the names of those who won the Nobel Prize from Sweden and the USA.
SELECT Winner FROM Nobel WHERE Country IN ('Sweden', 'USA');
OR
SELECT Winner FROM Nobel WHERE Country='Sweden' or Country='USA';
19.Display the last 3 characters of the winners' country names for those who won the prize after 1975.
SELECT SUBSTR(Country, -3) FROM Nobel WHERE Year > 1975;
OR
SELECT SUBSTRING(Country, -3) FROM Nobel WHERE Year > 1975;
OR
SELECT MID(Country, -3) FROM Nobel WHERE Year > 1975;
OR
SELECT RIGHT(Country, 3) FROM Nobel WHERE Year > 1975;
OR
SELECT SUBSTR(Country, length(country)-2,3) FROM Nobel WHERE Year > 1975;
OR
SELECT SUBSTRING(Country, length(country)-2,3) FROM Nobel WHERE Year > 1975;
OR
SELECT MID(Country, length(country)-2,3) FROM Nobel WHERE Year > 1975;

Lovejeet Arora

You might also like