Assume the greyhound breed is represented as

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: SELECT COUNT(dogid) FROM dogs; e. SELECT COUNT(DISTINCT breed) FROM dogs; e The others don’t even use the “breed” column. 6. Which query should you issue to find the user id of the user with the most dogs along with the number of dogs the user owns? The query should return only one row in the case where there are multiple users with the same number of dogs. On the answer sheet (not here!) mark a single letter for the query of your choice in the box below. [2pt] a. SELECT userid, COUNT(*) as cnt FROM dogs, users WHERE userid = dogid ORDER BY cnt DESC LIMIT 1; b. SELECT userid, MAX(dogid) as max FROM dogs,users WHERE userid = owner GROUP BY dogid, userid ORDER BY max DESC LIMIT 1; c. SELECT userid, MAX(dogid) as max FROM dogs,users WHERE userid = owner GROUP BY userid ORDER BY max DESC LIMIT 1; d. SELECT userid, COUNT(*) as cnt FROM dogs,users WHERE userid = owner GROUP BY userid ORDER BY cn...
View Full Document

This note was uploaded on 01/24/2014 for the course CS 186 taught by Professor Staff during the Fall '08 term at University of California, Berkeley.

Ask a homework question - tutors are online