Preview

SQL Queries

Satisfactory Essays
Open Document
Open Document
423 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
SQL Queries
Include Name

Tables:

STUDENT FACULTY CLASS ENROLL
PK StuID PK FacID PK ClassID FK ClassID
StuName FacName FK FacID FK StuID
Major Dept Sched Grade
Credits Rank Room

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?
The tables needed include: Student, Class, Enroll
These tables would be linked together by foreign keys; Enroll Table would be linked to Student table by FKStuID; Class would be linked to Enroll Table by FK ClassID

For the requested query above, what, if any, criteria would you use and on what field(s)?

Student Name and grade for all students taking a class in Room H201
SELECT S.StuName, Grade
FROM Student S, Enroll E, Class C
WHERE C.Room = ‘H201’;

Suppose you wanted to change the query above to also only show students with a grade of A or B? What would you change?
To change the query above and have it only show students with a grade of A or B I would add criteria to the grade field where e.grade = ‘A’ OR E.Grade = ‘B’;

Given the table information above, create the following queries using SQL:
Query 1: Find the names, ID's, and number of credits of all students who are math majors. The result should be a three column table.
SELECT Name, StudentID, Credits
FROM Students
WHERE Major = ‘Math’;

Query 2: Find the ClassID of all classes in which students are enrolled. The result should be a one column table, and no ClassID should appear more than once in that column.
SELECT DISTINCT ClassID
FROM Class;
Query 3: Find the names and ID's of all faculty members, sorted in reverse alphabetical order by name. The result should be a two column table (SELECT should only be two in order for the table to be 2 columns)
SELECT FacName, FacID
FROM Faculty
ORDER BY FacName DEC;

Query 4: Find the

You May Also Find These Documents Helpful

  • Satisfactory Essays

    PT2520 Unit7Labs Tramil

    • 330 Words
    • 1 Page

    3. What is a foreign key? This primary key becomes a foreign key when it is repeated in another table to create a link between the tables.…

    • 330 Words
    • 1 Page
    Satisfactory Essays
  • Powerful Essays

    Simpson Case ACL

    • 651 Words
    • 10 Pages

    Question 4. Determine whether the record counts in the three tables are consistent with the information you received from the IT department.…

    • 651 Words
    • 10 Pages
    Powerful Essays
  • Satisfactory Essays

    Answer all the questions in Part A on the answer sheet provided, using pencil . only: Print your student number, name and initials in the space provided and mark…

    • 472 Words
    • 2 Pages
    Satisfactory 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
  • Good Essays

    Kudler Fine Food Week 4

    • 284 Words
    • 2 Pages

    Note: Select all of the data from both of your tables before you perform the following.…

    • 284 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    CTS 2437 Final Exam

    • 630 Words
    • 4 Pages

    Before providing a solution for any of the following problems, create the Faculty database. This is attached to the Final Exam—Part 2 link in Blackboard.…

    • 630 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    cis3730_Exam1_Studyguide

    • 512 Words
    • 2 Pages

    Be able to give examples of tables, specify their primary keys, and explain how they are related through foreign keys.…

    • 512 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    You are required to use OpenOffice software to write and execute queries with tables you created in project prt 1.…

    • 325 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The rules help in shaping and providing the best database program that the college will use. One of the business rules is that the database will only be accessed by the database administrator or the heads of department. This way, students and instructors will not be able to alter any information without seeking for permission first. Results from the database will also be trusted because they are based on true facts that have taken place thought the course (Halpin& Morgan, 2008). The second rule is that all entities should understand their roles in the college. Departments will be responsible for offering courses. Classes will be generated based on the course. Instructors will be expected to teach the students in class. The students will be expected to learn from the instructor and perform well. Once all entities have known their roles, it will be easy to maintain and work with the database. Everybody will be expected to play their part to ensure that the college produces good…

    • 590 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Nt1310 Unit 1 Assignment

    • 2064 Words
    • 9 Pages

    Student C: (………………..Put your own name & School ID #, Group #(1,2,3,4), University group (P,H,C,Y) here)…

    • 2064 Words
    • 9 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Scavenger Hunt

    • 596 Words
    • 3 Pages

    7. Where on your student Web site will you be able to find your schedule and course grades for all courses completed to date?…

    • 596 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Comm 461 Case Study

    • 3109 Words
    • 13 Pages

    Markstrat and case grade to arrive at the student's grade for all projects. For example, if a…

    • 3109 Words
    • 13 Pages
    Powerful Essays
  • Powerful Essays

    Introduction to Oracle 9i: SQL Name: _______ Junel L Cofino Table of Contents Introduction: I-7 - Relational and Object Relational Database Management System I-10 - System Development Life Cycle I-12 - Relational Database Concept I-20 - Relational Database Properties I-24 - Tables used in the course Chapter 1: Writing Basic SELECT SQL Statements 1-4- Basic Select Statement 1-5- Selecting All Columns 1- 6- Selecting Specific Columns 1-7- Writing SQL Statements 1-8- Column Heading Defaults 1-9- Arithmetic Expressions 1-15- Null Values in Arithmetic Expressions 1-16- Defining A Column Alias 1-17- Using Column Alias 1-18- Concatenation Operator 1-19- Using Concatenation Operator 1-22- Duplicate Rows 1-23- Eliminating Duplicate Rows Chapter 2: Restricting and Sorting Data 2-4-Limiting the Rows Selected 2-5-Using WHERE Clause 2-6- Character Strings and Dates 2-7- Comparison Conditions 2-8- Using Comparison Conditions 2-9- Other Comparison Conditions 2-10- Using the BETWEEN Condition…

    • 1047 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    Mysql

    • 840 Words
    • 4 Pages

    Query OK, 1 row affected (0.06 sec) mysql> insert into salesman1 values("sB","Rohan","Delhi",25000,"Notebook",150); Query OK, 1 row affected (0.28 sec) mysql> insert into salesman1 values("sC","Jitu","Mumbai",21200,"Paper",250); Query OK, 1 row affected (0.31 sec) mysql> insert into salesman1 values("sD","Atul","Ghaziabad",10200,"Register",300 ); Query OK, 1 row affected (0.30 sec)…

    • 840 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    1.create table role(Id BIGINT(20), name varchar(255) NOT NULL,primary key(Id)); 2.create table skill(Id BIGINT(20)primary key, description varchar(255) NULL, name varchar(255) NOT NULL); 3.create table post_type(Id BIGINT(20)primary key,name varchar(255) NOT NULL); 4.create table department(Id BIGINT(20)primary key, name varchar(255) NOT NULL); 5.create table degree ( Id BIGINT(20)primary key, department_id BIGINT(20) NOT NULL, name varchar(255) NOT NULL, FOREIGN KEY(department_id) REFERENCES department(Id) ) ; 6. create table profile ( Id BIGINT(20)primary key, address varchar(255) NOT NULL, batch varchar(255)…

    • 899 Words
    • 6 Pages
    Good Essays

Related Topics