SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name ORDER BY count(*) DESC LIMIT 3
What are the three products that have the most problems?s
CREATE TABLE `Problem_Category_Codes` (
`problem_category_code` VARCHAR(20) PRIMARY KEY,
`problem_category_description` VARCHAR(80)
);
CREATE TABLE `Problem_Log` (
`problem_log_id` INTEGER PRIMARY KEY,
`assigned_to_staff_id` INTEGER NOT NULL,
`problem_id` INTEGER NOT NULL,
`problem_category_code` VARCHAR(20) NOT NULL,
`problem_status_code` VARCHAR(20) NOT NULL,
`log_entry_date` DATETIME,
`log_entry_description` VARCHAR(255),
`log_entry_fix` VARCHAR(255),
`other_log_details` VARCHAR(255),
FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` )
);
CREATE TABLE `Problem_Status_Codes` (
`problem_status_code` VARCHAR(20) PRIMARY KEY,
`problem_status_description` VARCHAR(80)
);
CREATE TABLE `Product` (
`product_id` INTEGER PRIMARY KEY,
`product_name` VARCHAR(80),
`product_details` VARCHAR(255)
);
CREATE TABLE `Staff` (
`staff_id` INTEGER PRIMARY KEY,
`staff_first_name` VARCHAR(80),
`staff_last_name` VARCHAR(80),
`other_staff_details` VARCHAR(255)
);
CREATE TABLE `Problems` (
`problem_id` INTEGER PRIMARY KEY,
`product_id` INTEGER NOT NULL,
`closure_authorised_by_staff_id` INTEGER NOT NULL,
`reported_by_staff_id` INTEGER NOT NULL,
`date_problem_reported` DATETIME NOT NULL,
`date_problem_closed` DATETIME,
`problem_description` VARCHAR(255),
`other_problem_details` VARCHAR(255),
FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ),
FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ),
FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` )
);
INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.');
INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported');
INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm');
INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k');
INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p');
INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p');