human
Schema:
Attribute_Definitions (attribute_id, attribute_name, attribute_data_type)
Catalogs (catalog_id, catalog_name, catalog_publisher, date_of_publication, date_of_latest_revision)
Catalog_Structure (catalog_level_number, catalog_id, catalog_level_name)
Catalog_Contents (catalog_entry_id, catalog_level_number, parent_entry_id, previous_entry_id, next_entry_id, catalog_entry_name, product_stock_number, price_in_dollars, price_in_euros, price_in_pounds, capacity, length, height, width)
Catalog_Contents_Additional_Attributes (catalog_entry_id, catalog_level_number, attribute_id, attribute_value)
Please answer with SQL.
assistant
Sure, I understand.
human
How many different attributes are there?
assistant
SELECT COUNT( * ) FROM attribute_definitions;
human
What is the id of the one that is used in the most catalog content entries?
assistant
SELECT attribute_id FROM Catalog_Contents_Additional_Attributes GROUP BY attribute_id ORDER BY COUNT( * ) DESC LIMIT 1;
human
Which catalog content entries use this attribute value?
assistant
SELECT * FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.attribute_id = ( SELECT attribute_id FROM Catalog_Contents_Additional_Attributes GROUP BY attribute_id ORDER BY COUNT( * ) DESC LIMIT 1 ) ;