Sie sind auf Seite 1von 5

1.

Write a SQL statement to display the PetID, PetBreed, and PetType for all pets having a fourcharacter PetName starting with K. (see pg 139-140)
So when I Ran this first Query I did not get any results (Which is odd because it should work
considering the second Query I ran did.

2. Write a SQL statement to display the OwnerLastName, OwnerFirstName and OwnerEmail of all
owners who have an email address ending with somewhere.com. Assume that email account names
can be any number of characters.

3. Write a SQL statement to display the OwnerLastName, OwnerFirstName and OwnerEmail of any
owner who has a NULL value for OwnerPhone. (be aware that NULL can be either a word or a
parameter, depending on how it's used in your code.)

4. Write a SQL statement to display the PetName and PetBreed of all pets sorted by PetName.

5. Write a SQL statement to display the PetName and PetBreed of all pets sorted by PetBreed in
ascending order and by PetName in descending order within PetBreed.

6. Write a SQL statement to count the number of pets.

7. Write a SQL statement to count the number of distinct (see glossary & Index) breeds.

8. Write the required SQL statements to create the above PET 3 table, and to insert the data shown in
the above Figure 3-17. Assume PetWeight is Numeric(4,1).

9. Write an SQL statement to display the minimum, maximum, and average weight of dogs.

10. Write an SQL statement to group the data by PetBreed and display the average Weight per breed.

11. Answer question 10, but consider only breeds for which two or more pets are included in the
database.

12. Answer question 10, but do not consider any pet having PetBreed Unknown.

13. Write a SQL statement to add a PetWeight column, like the one in PET_3, to the PET table, given
that this column is NULL. Again, assume Weight is Numeric(4,1).

14. Write a SQL statement to display the OwnerLastName, OwnerFirstName and OwnerEmail of any
owners of cats. (Note that this question and #15 need to query both the Pet and Owner tables. There
are no pet types in the Owner table.)

15. Write an SQL statement to display the OwnerLastName, OwnerFirstName, PetName, PetType,
PetBreed and PetDOB for pets with a known PetBreed.

Das könnte Ihnen auch gefallen