Preview

Sql Practice Questions

Powerful Essays
Open Document
Open Document
1077 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Sql Practice Questions
SQL Practice Questions

Consider the following schema definitions: Branch (branchNo, street, city, postcode) Staff (staffNo, fName,lName, position, sex, DOB, salary, branchNo) PropertyforRent (propertyNo, street, city, postcode, type, rooms, rent, ownerNo, staffNo, branchNo) Client (clientNo, fName, lName, telNo, prefType, maxRent) PrivateOwner (ownerNo, fName, lName, address, telNo) Viewing (clientNo, propertyNo, viewDate, comment) Registration (clientNo, branchNo, staffNo, dateJoined)

An instance of the above schemas is given in the last page of the examination. (You may detach and use it if necessary)

For each case below, fill in the blanks such that the SQL queries correspond to the English language queries stated. Each blank is worth 2 points.

1. List the address of all branch offices in London or Bristol.

SELECT _______*_______ FROM ___branch______ WHERE city=’London’ _OR city=’bristol’______

2. List the staff with a salary between $10000 and $30000.

SELECT staff_No FROM Staff WHERE __salary between 10000 AND 30000________________

3. List the staff in descending order of salary.

SELECT staff_No, salary FROM Staff ORDER BY __salary DESC__________________

4. Find the number of different properties viewed in April 2004.

SELECT __count (distinct propert_no) FROM Viewing WHERE viewDate BETWEEN ‘1-Apr-04’ AND ’30-Apr-04’

5. Find the minimum, maximum and average staff salary.

SELECT _min(salary)____, _max(salary)_, _avg(salary)_____ FROM Staff

6. For each branch office with more than one member of staff, find the number of staff working in each branch and the sum of their salaries.

SELECT branchNo, _count(staffno)_, __sum(salary)___ FROM Staff GROUP BY branchNo HAVING __count(staffNo) >1

7. List the staff who work in the

You May Also Find These Documents Helpful

  • Good Essays

    Pt1420 Unit 21 Quiz

    • 1899 Words
    • 8 Pages

    Complete these answers in your own words. Follow instructions in the Final Examination document. Answer all questions according to the instructions. Number each question here according to its number in the Final Examination document provided by your…

    • 1899 Words
    • 8 Pages
    Good Essays
  • Good Essays

    1. SELECT e.ename, e.deptno, d.dname, d.deptno FROM dept d LEFT OUTER JOIN emp e ON d.deptno = e.deptno ORDER BY d.deptno; SQL> SELECT e.ename, e.deptno, d.dname, d.deptno 2 FROM dept d 3 LEFT OUTER JOIN emp e 4 ON d.deptno = e.deptno 5 ORDER BY d.deptno; ENAME DEPTNO DNAME DEPTNO ---------- ---------- -------------- ----------…

    • 1542 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    cis3730_Exam1_Studyguide

    • 512 Words
    • 2 Pages

    You will be asked to write SQL scripts to display required information, like we did in the homework.…

    • 512 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    BMIS 325 Phase II Part A: Table Creation and Data Loading Part B: Reports 1.) Human Resources: Select Regions. RegionName, Countries. CountryName, concat(Employees. LastName, ', ' ,Employees.…

    • 485 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 6

    • 360 Words
    • 2 Pages

    13) The WHERE clause is used to set criteria by which to filter which rows are returned or affected.…

    • 360 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    DBQ Questions

    • 781 Words
    • 4 Pages

    Evaluate the effectiveness and intent of the U.S. Government in dealing with the slavery issue from 1787-1857.…

    • 781 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    9. Which of the following includes a customer with the first name BONITA in the results?…

    • 396 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    data to be ready for producing meaningful output from the DBMS?d) 5 What are two main forms of output from a DBMS? Provide one example of each form of output using…

    • 1445 Words
    • 6 Pages
    Powerful Essays
  • Good Essays

    Student Name ______________________________________________________________ School Name _______________________________________________________________ The possession or use of any communications device is strictly prohibited when taking this examination. If you have or use any communications device, no matter how briefly, your examination will be invalidated and no score will be calculated for you. Print your name and the name of your school on the lines above. A separate answer sheet for Part I has been provided to you. Follow the instructions from the proctor for completing the student information on your answer sheet. Then fill in the heading of each page of your essay booklet. This examination has three parts. You are to answer all questions in all parts. Use black or dark-blue ink to write your answers to Parts II, III A, and III B. Part I contains 50 multiple-choice questions. Record your answers to these questions as directed on the answer sheet. Part II contains one thematic essay question. Write your answer to this question in the essay booklet, beginning on page 1. Part III is based on several documents: Part III A contains the documents. When you reach this part of the test, enter your name and the name of your school on the first page of this section. Each document is followed by one or more questions. Write your answer to each question in this examination booklet on the lines following that question. Part III B contains one essay question based on the documents. Write your answer to this question in the essay booklet, beginning on page 7. When you have completed the examination, you must sign the declaration printed at the end of the answer sheet, indicating that you had no unlawful knowledge of the questions or answers prior to the…

    • 7115 Words
    • 29 Pages
    Good Essays
  • Satisfactory Essays

    are attached at the end of the exam. Answer all questions in this booklet. The booklet…

    • 2530 Words
    • 27 Pages
    Satisfactory Essays
  • Better Essays

    Please complete the Module 4 EXAM Practice below. The practice will simulate the type of test you will be…

    • 4735 Words
    • 10 Pages
    Better Essays
  • Satisfactory Essays

    SQL Queries

    • 423 Words
    • 2 Pages

    Given the table information above, if you were asked to create an Access query that showed the Student Name and Grade for all students taking a class in Room H201, what tables would you need and how would you link them together?…

    • 423 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Week 1 Submission

    • 1120 Words
    • 5 Pages

    9. List the job, salary, and employee name in job order and then salary in descending order.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Please note that discussing the exam on the BB, by email, phone or other means are not allowed. Exam has to be done on your own.…

    • 2045 Words
    • 9 Pages
    Satisfactory Essays
  • Powerful Essays

    Business

    • 1870 Words
    • 8 Pages

    Number of pages (including cover page): 11 Instructions to Candidates: Please do the following as NO examination booklet is provided: 1. Mark your answers to Section 1 on the provided mark sensing sheet. 2. Write your answers to Sections 2, 3 and 4 on this paper. 3. Write your student number clearly on the front cover of this examination paper (see below). There are 4 Sections to this examination paper. i. Section 1 consists of 25 multiple choice questions (1 mark each correct answer = 25 marks) Section 2 consists of a four short answer questions (25 marks) Section 3 consists of three short answer questions (25 marks) Section 4 consists of three short answer questions (25 marks)…

    • 1870 Words
    • 8 Pages
    Powerful Essays