Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在按列分组的列P中按月计算下表中的平均值。per_datequ_def
P
per_date
qu_def
并将其存储在 SQL Server 表中,如下所示:
您似乎想要这样的查询:
select qu_def, for_cur, datefromparts(year(per_date), month(per_date), 1) as per_date, max(per_date) as date, avg(p) as p from t group by qu_def, for_cur, datefromparts(year(per_date), month(per_date), 1);
您可以使用INSERT将其放入现有表或INTO创建新表。
INSERT
INTO