Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

BSAN 310 SQL #1 Initial Exercise

1. In Live SQL ( https://livesql.oracle.com/apex/f?p=590:1000) create account.

After Logging In, click on “Start Coding Now” or Click on “SQL Worksheet” on top
left-side menu...you’ll see a screen similar to the one below:

We will use the database table below. [ the HR.EMPLOYEES table].

HR.EMPLOYEES

For this assignment, write the SQL statement in Live SQL and then run/execute it. Once
you see the result copy your SQL statement and paste it into this Word document (be sure
to save this Word document). I don’t need to see your output.

NOTE: To learn SQL you need to actually run the SQL statements in Live SQL. Every
semester students copy other students’ statements or type SQL statements and don’t run
them (they will have errors keeping them from running). This behavior will undermine
you learning SQL and reduces what you are learning in this course. For your own
benefit, don’t do this.

Once you complete all the problems, submit this Word document as your SQL
Assignment #1.

1. Write (and run) the SQL statement that would display (output) all the records/rows
and columns/attributes within the database table HR.EMPLOYEES. What this SQL
statement is doing is displaying all the employees in the HR.EMPLOYEES table and
with this display, it shows you what data is in the HR.EMPLOYEES table for each of
these employees (e.g. their employee ID number, first name, last name, email, phone
number etc).

SELECT * FROM HR.EMPLOYEES; [This is an example of your answer for the first
question]

2. Now, instead of displaying all the columns/attributes of the entire HR.EMPLOYEES


table with all the rows/records within them (as you did in problem #1), write and run an
SQL statement that will only display all the rows/records in the HR.EMPLOYEES table
(again, like problem #1 this is displaying all the employees in the HR.EMPLOYEES
table) but will only display their last names and salaries (the column names are
last_name, salary). This output will not display other data on these employees like their
email, phone number etc. You can look at your output from #1 to determine how to spell
the column names/attributes.

3. What would your SQL statement be if you want the same output/display from
question #2 but you want the column/attribute salary to be displayed first? Cut-and-paste
your SQL statement below: SELECT salary, last_name FROM HR.EMPLOYEES

4. Cut and paste the following SQL statement into LIVE SQL and then run it:

SELECT JOB_ID
FROM HR.EMPLOYEES;

Thoroughly explain to me what this SQL statement is accomplishing...(I don’t need to see
your output here...you just need to describe what this SQL statement is doing).

It display all columns/attributes of JOB_ID


5. From the output of the SQL statement from “SELECT job_id FROM
HR.EMPLOYEES;”, you can see that several of the JOB_IDs are duplicated in the output
(such as FI_ACCOUNT and IT_PROG).

Now, run this same SQL statement but modify it so there won’t be any duplicate
JOB_IDs displayed in the output. Cut and paste your SQL statement below after you run
it and see the output in LIVE SQL. SELECT DISTINCT JOB_ID FROM
HR.EMPLOYEES;

You might also like