Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE PET_3 (
- id INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- PetName VARCHAR(30) NOT NULL,
- PetType VARCHAR(30) NOT NULL,
- PetBreed VARCHAR(30) NOT NULL,
- PetDOB VARCHAR(30) NOT NULL,
- PetWeight DECIMAL(5,2) NOT NULL,
- OwnerID INTEGER UNSIGNED NOT NULL
- );
- INSERT INTO `PET_3` (`PetName`, `PetType`, `PetBreed`, `PetDOB`, `PetWeight`, `OwnerID`) VALUES ('King', 'Dog', 'Std. Poodle', '27-Feb-11', 25.5, 1);
- INSERT INTO `PET_3` (`PetName`, `PetType`, `PetBreed`, `PetDOB`, `PetWeight`, `OwnerID`) VALUES ('King', 'Dog', 'Std. Poodle', '27-Feb-11', 10.5, 2);
- INSERT INTO `PET_3` (`PetName`, `PetType`, `PetBreed`, `PetDOB`, `PetWeight`, `OwnerID`) VALUES ('King', 'Dog', 'Std. Poodle', '27-Feb-11', 28.5, 3);
- INSERT INTO `PET_3` (`PetName`, `PetType`, `PetBreed`, `PetDOB`, `PetWeight`, `OwnerID`) VALUES ('King', 'Dog', 'Cashmere', '27-Feb-11', 9.5, 4);
- INSERT INTO `PET_3` (`PetName`, `PetType`, `PetBreed`, `PetDOB`, `PetWeight`, `OwnerID`) VALUES ('King', 'Dog', 'Cashmere', '27-Feb-11', 25, 5);
- INSERT INTO `PET_3` (`PetName`, `PetType`, `PetBreed`, `PetDOB`, `PetWeight`, `OwnerID`) VALUES ('King', 'Dog', 'Cashmere', '27-Feb-11', 20.0, 6);
- INSERT INTO `PET_3` (`PetName`, `PetType`, `PetBreed`, `PetDOB`, `PetWeight`, `OwnerID`) VALUES ('King', 'Dog', 'Unknow', '27-Feb-11', 30, 7);
- SELECT AVG(PetWeight) AS AverageWeight, PetBreed, COUNT(PetBreed) AS PetCount
- FROM PET_3
- GROUP BY `PetBreed`
- HAVING PetCount > 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement