Year 11 Exam  >  Year 11 Notes  >  Computer for GCSE/IGCSE  >  SQL

SQL | Computer for GCSE/IGCSE - Year 11 PDF Download

SQL

  • Structured Query Language (SQL) enables searching and manipulation of data in databases.
  • SQL statements are crafted to interrogate the database and retrieve pertinent information.
  • SQL statements adhere to this structure:
    • SELECT the desired fields for display.
    • FROM the table/tables housing the data to be searched.
    • WHERE specifies the search criteria.

A Database Table Containing Movie Details

SQL | Computer for GCSE/IGCSE - Year 11

Example:
SELECT Name, Rating
FROM Movie
WHERE Rating>8.4;

The results of this query would be:

SQL | Computer for GCSE/IGCSE - Year 11

  • Two fields, Name and Rating, have been extracted from the Movie table, and subsequently, the records have been filtered based on the Rating.
  • In this instance, the > operator is employed to search for records with a rating exceeding 8.4.
  • Numerous other comparison operators can be utilized to establish filter criteria within the WHERE clause of a SQL query.

SQL Comparison Operators

SQL | Computer for GCSE/IGCSE - Year 11

Example:
SELECT Name,Rating
FROM Movie
WHERE Genre=”Family” AND Certificate=”U”;

The results of this query would be:SQL | Computer for GCSE/IGCSE - Year 11

  • Two fields, Name and Rating, have been extracted from the Movie table, and the records have been filtered by both Genre and Certificate.
  • This query employs the AND logical operator to incorporate multiple criteria in the WHERE clause of the SQL query.
  • Another logical operator applicable in the WHERE statement is OR:
    • For instance, WHERE Genre="Comedy" OR Genre="Family".

ORDER BY

An additional line can be appended to the statement using the ORDER BY command, followed by ASC or DESC:

  • When ASC is specified, the query results are sorted in ascending order.
  • Conversely, when DESC is specified, the query results are sorted in descending order.

Example:
SELECT Name,Genre, Certificate, Rating
FROM Movie
ORDER BY Name ASC

The results of this query would be:
SQL | Computer for GCSE/IGCSE - Year 11

The query has retrieved four fields and all records due to the absence of WHERE criteria. The records are sorted alphabetically by Name.

  • When sorted in ascending order, numbers ascend from the lowest at the top to the highest at the bottom.
  • Conversely, in descending order, numbers descend from the highest at the top to the lowest at the bottom.

SUM and COUNT commands

  • The SUM command can be used to add numerical data
  • The COUNT command can be used to count items of data

SQL | Computer for GCSE/IGCSE - Year 11

Example:
SELECT SUM(QuantityInStock)
FROM ProductTable;

  • This query will add up all of the numbers in the QuantityInStock field
    • The result of this query would be 25 

Example:
SELECT COUNT(*)
FROM ProductTable
WHERE Price>2;

  • This query will count all the records with a price greater than 2
    • The result of this query would be 3
    • This is because there are three products with a price greater than £2 (Chips, Beans, Bananas)
The document SQL | Computer for GCSE/IGCSE - Year 11 is a part of the Year 11 Course Computer for GCSE/IGCSE.
All you need of Year 11 at this link: Year 11
92 docs|30 tests

Top Courses for Year 11

92 docs|30 tests
Download as PDF
Explore Courses for Year 11 exam

Top Courses for Year 11

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

past year papers

,

video lectures

,

study material

,

practice quizzes

,

SQL | Computer for GCSE/IGCSE - Year 11

,

Extra Questions

,

Previous Year Questions with Solutions

,

SQL | Computer for GCSE/IGCSE - Year 11

,

Summary

,

mock tests for examination

,

Sample Paper

,

MCQs

,

Semester Notes

,

ppt

,

SQL | Computer for GCSE/IGCSE - Year 11

,

pdf

,

Free

,

Objective type Questions

,

shortcuts and tricks

,

Viva Questions

,

Exam

,

Important questions

;