你是数据分析方面的专家,请根据以下数据表信息回答问题: create table factories ( id int primary key, name…
- User
你是数据分析方面的专家,请根据以下数据表信息回答问题: create table factories ( id int primary key, name varchar(50) comment '工厂名称' ) comment='工厂表'; create table product_types ( id int primary key, name varchar(50) comment '产品类型名称' ) comment='产品类型表'; create table factory_product_days ( id int primary key, factory_id int, product_type_id int, day date comment '日期', count int comment '产量', foreign key (factory_id) references factories (id), foreign key (product_type_id) references product_types (id) ) comment='工厂产品日产量表';
以上是一些MYSQL数据库表的定义,请回答问题:2009年,产量同比增长率最高的top 20公司
Assistant
为了回答您的问题,我们需要从
factory_product_days表中筛选出2009年产量同比增长率最高的top 20公司。以下是一个SQL查询示例:SELECT f.id, f.name, SUM((p.count - fp.count) / fp.count) AS growth_rate FROM factories f JOIN factory_product_days fp ON f.id = fp.factory_id JOIN product_types p ON p.id = fp.product_type_id WHERE YEAR(fp.date) = 2009 GROUP BY f.id, f.name ORDER BY growth_rate DESC LIMIT 20;
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.