0% found this document useful (0 votes)
60 views

Chapter 9 Database 2023

The document is a specimen paper for a computer science class on databases compiled by teacher Lubna Tanweer. It covers SQL commands like SELECT, FROM, WHERE, and ORDER BY. It explains how to select specific fields or all fields from a table, add conditions to a query, and sort results. The document also demonstrates SUM and COUNT functions and includes sample exam questions from previous years.

Uploaded by

miqureshi77
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Chapter 9 Database 2023

The document is a specimen paper for a computer science class on databases compiled by teacher Lubna Tanweer. It covers SQL commands like SELECT, FROM, WHERE, and ORDER BY. It explains how to select specific fields or all fields from a table, add conditions to a query, and sort results. The document also demonstrates SUM and COUNT functions and includes sample exam questions from previous years.

Uploaded by

miqureshi77
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

Teacher Name: Lubna Tanweer


Student Name :__________________________________________ Class:_______ Section:__________

Specimen paper 2015 Chapter 9 DATABASE

Page 1 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

Only the SELECT and FROM commands are mandatory in an SQL script.
All other commands are optional.

A SELECT statement takes the form:


SELECT Field1, Field2, Field3

– this specifies the individual fields (columns) to be shown.

SELECT *

– this specifies that all fields (columns) are to be shown.

A FROM statement takes the form:


FROM TableName

– this specifies the table to use.

A WHERE statement takes the form:


WHERE Condition

WHERE Staffname = ‘Mr Smith’

WHERE Gender = ‘M’

WHERE FeePaid = TRUE

WHERE Class =11 AND Section = “E”

WHERE (Weight > 60.5 AND Weight <75) AND ( Height > 65)

WHERE ExpDate < ‘31/12/2022’

– this specifies the condition to apply.

An ORDER BY statement takes the form:


ORDER BY Field1, Field2

– this specifies a sort in ascending or alphabetical order starting with the first field.

ORDER BY Field1, Field2 DESC

– this specifies a sort in descending or reverse alphabetical order starting with the first field.

Page 2 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

Page 3 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

A SUM statement takes the form:


SELECT SUM (Field)

– this specifies the field (column) for the calculation.

The field should be integer or real.

A COUNT statement takes the form:


SELECT COUNT (Field)

– this specifies the field (column) to count if the given criterium is met.

2210_s15_qp21

Page 4 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s15_qp22

Page 5 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w15_qp22

Page 6 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w15_qp23

Page 7 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s16_qp21

Page 8 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s16_qp22

Page 9 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w16_qp22

Page 10 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w16_qp23

Page 11 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s17_qp21

Page 12 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s17_qp22

Page 13 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w17_qp22

2210_w17_qp23

Page 14 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s18_qp21

Page 15 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s18_qp22

Page 16 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w18_qp22

Page 17 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w18_qp23

Page 18 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s19_qp21

Page 19 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s19_qp21

Page 20 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

Page 21 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w19_qp22

Page 22 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_w19_qp23

2210_s2020_qp21

Page 23 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

Page 24 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

2210_s2020_qp22

Page 25 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

W20_qp22

Page 26 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

W20_qp23

Page 27 of 28 Compiled by Ms Lubna Tanweer


BSS PECHS CAMPUS COMPUTER SCIENCE SESSION 2022-23

S21_qp21

Page 28 of 28 Compiled by Ms Lubna Tanweer

You might also like