Logo 
Search:

Oracle Articles

Submit Article
Home » Articles » Oracle » DatabaseRSS Feeds

Use the FRIENDS table to answer the following questions

Posted By: Adelhelm Fischer     Category: Oracle     Views: 2881

Use the FRIENDS table to answer the following questions.

Use the FRIENDS table to answer the following questions.

LASTNAME    FIRSTNAME      AREACODE       PHONE    ST     ZIP
------------      -----------------  --------------       -----------    ----     -----
BUNDY            AL                      100                      555-1111    IL      22333
MEZA              AL                      200                      555-2222    UK
MERRICK       BUD                   300                      555-6666    CO    80212
MAST              JD                      381                      555-6767     LA    23456
BULHER          FERRIS             345                      555-3223     IL     23332
PERKINS         ALTON             911                      555-3116     CA    95633
BOSS               SIR                   204                       555-2345     CT    95633

Write a query that returns everyone in the database whose last name begins with M. 

SELECT * FROM FRIENDS WHERE LASTNAME LIKE 'M%';

Write a query that returns everyone who lives in Illinois with a first name of AL. 

SELECT * FROM FRIENDS
WHERE STATE = 'IL'
AND FIRSTNAME = 'AL';

Given two tables (PART1 and PART2) containing columns named PARTNO, how would you find out which part numbers are in both tables? Write the query. 

Use the INTERSECT. Remember that INTERSECT returns rows common to both queries. 
SELECT PARTNO FROM PART1
INTERSECT
SELECT PARTNO FROM PART2;

What shorthand could you use instead of WHERE a >= 10 AND a <=30? 

WHERE a BETWEEN 10 AND 30;

What will this query return? 

SELECT FIRSTNAME
FROM FRIENDS
WHERE FIRSTNAME = 'AL'
  AND LASTNAME = 'BULHER';

Nothing will be returned, as both conditions are not true. 

Using the FRIENDS table, write a query that returns the following: 

NAME                ST
------------------- --
AL             FROM IL

SELECT (FIRSTNAME || 'FROM') NAME, STATE
FROM FRIENDS
WHERE STATE = 'IL'
AND
LASTNAME = 'BUNDY';

Using the FRIENDS table, write a query that returns the following: 

NAME                          PHONE
---------------------      ------------
MERRICK, BUD            300-555-6666
MAST, JD                     381-555-6767
BULHER, FERRIS          345-555-3223

SELECT LASTNAME || ',' || FIRSTNAME NAME,
AREACODE || '-' || PHONE PHONE
FROM FRIENDS
WHERE AREACODE BETWEEN 300 AND 400;
  
Share: 


Didn't find what you were looking for? Find more on Use the FRIENDS table to answer the following questions Or get search suggestion and latest updates.

Adelhelm Fischer
Adelhelm Fischer author of Use the FRIENDS table to answer the following questions is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!