ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

La instrucción Select ejercicios Enter seleccione la solicitud


Enviado por   •  10 de Agosto de 2014  •  Trabajos  •  905 Palabras (4 Páginas)  •  278 Visitas

Página 1 de 4

Select statement exercises

Enter select statements to:

1. Display the first name and age for everyone that's in the table.

R: select first, age, from empinfo;

2. Display the first name, last name, and city for everyone that's not from Payson.

R: select first, last, city, from empinfo where city <> 'Payson'

first last city

Eric Edwards San Diego

Mary Ann Edwards Phoenix

Ginger Howell Cottonwood

Sebastian Smith Gila Bend

Gus Gray Bagdad

Mary Ann May Tucson

Erica Williams Show Low

Leroy Brown Pinetop

Elroy Cleaver Globe

3. Display all columns for everyone that is over 40 years old.

R: select * from empinfo

where age > 40;

first last id age city state

John Jones 99980 45 Payson Arizona

Ginger Howell 98002 42 Cottonwood Arizona

Mary Ann May 32326 52 Tucson Arizona

Erica Williams 32327 60 Show Low Arizona

4. Display the first and last names for everyone whose last name ends in an "ay".

R: select first, last, from empinfo

where last LIKE '%ay';

first last

Gus Gray

Mary Ann May

5. Display all columns for everyone whose first name equals "Mary".

R: select * from empinfo

where first = 'Mary';

first last id age city state

Mary Jones 99982 25 Payson Arizona

6. Display all columns for everyone whose first name contains "Mary".

R: select * from empinfo

where first LIKE '%Mary%';

first last id age city state

Mary Jones 99982 25 Payson Arizona

Mary Ann Edwards 88233 32 Phoenix Arizona

Mary Ann May 32326 52 Tucson Arizona

4. Creating Tables

Create Table Exercise

You have just started a new company. It is time to hire some employees. You will need to create a table that will contain the following information about your new employees: firstname, lastname, title, age, and salary. After you create the table, you should receive a small form on the screen with the appropriate column names. If you are missing any columns, you need to double check your SQL statement and recreate the table. Once it's created successfully, go to the "Insert" lesson.

create table Fernando_g

firstname lastname title age salary

(firstname varchar(18) not null,

lastname varchar(20) not null,

title varchar(20 not null),

age number(3) not null,

salary number(6) not null);

5. Inserting into a Table

Insert statement exercises

It is time to insert data into your new employee table.

Your first three employees are the following:

Jonie Weber, Secretary, 28, 19500.00

Potsy Weber, Programmer, 32, 45300.00

Dirk Smith, Programmer II, 45, 75020.00

insert into Fernando_g

(firstname, lastname, title, age, salary)

values ('Jonie', 'Weber', 'Secretary', 28, 19500);

insert into Fernando_g

(firstname, lastname, title, age, salary)

values ('Potsy', 'Weber', 'Programmer', 32, 45300);

insert into Fernando_g

(firstname, lastname, title, age, salary)

values ('Dirk', 'Smith', 'Programmer II', 45, 75020);

Enter these employees into your table first, and then insert at least 5 more of your own list of employees in the table.

After they're inserted into the table, enter select statements to:

1. Select all columns for everyone in your employee table.

R: Select * from Fernando_g;

firstname lastname title age salary

Jonie Weber Secretary 28 19500

Potsy Weber Programmer 32 45300

Dirk Smith Programmer II 45 75020

2. Select all columns for everyone with a salary over 30000.

R:

...

Descargar como (para miembros actualizados)  txt (6.9 Kb)  
Leer 3 páginas más »
Disponible sólo en Clubensayos.com