根據資料表統計某地某年農作物種植面積
select *from t_distribution ;
select sum(area_num) as "2016總面積" from t_distribution where ad_area_code like '6103%' and current_year ='2016';
select sum(area_num) as "2016小麥面積" from t_distribution where ad_area_code like '6103%' and flag ='0' and current_year ='2016';
select sum(area_num) as "2016玉公尺面積" from t_distribution where ad_area_code like '6103%' and flag ='1' and current_year ='2016';
select sum(area_num) as "2016其他面積" from t_distribution where ad_area_code like '6103%' and flag ='2' and current_year ='2016';
select sum(area_num) as "2017總面積" from t_distribution where ad_area_code like '6103%' and current_year ='2017';
select sum(area_num) as "2017小麥面積" from t_distribution where ad_area_code like '6103%' and flag ='0' and current_year ='2017';
select sum(area_num) as "2017玉公尺面積" from t_distribution where ad_area_code like '6103%' and flag ='1' and current_year ='2017';
select sum(area_num) as "2017其他面積" from t_distribution where ad_area_code like '6103%' and flag ='2' and current_year ='2017';
select sum(area_num) as "2018總面積" from t_distribution where ad_area_code like '6103%' and current_year ='2018';
select sum(area_num) as "2018小麥面積" from t_distribution where ad_area_code like '6103%' and flag ='0' and current_year ='2018';
select sum(area_num) as "2018玉公尺面積" from t_distribution where ad_area_code like '6103%' and flag ='1' and current_year ='2018';
select sum(area_num) as "2018其他面積" from t_distribution where ad_area_code like '6103%' and flag ='2' and current_year ='2018';
select sum(area_num) as "總面積" from t_distribution where ad_area_code like '6103%' and current_year ='2019';
select sum(area_num) as "小麥面積" from t_distribution where ad_area_code like '6103%' and flag ='0' and current_year ='2019';
select sum(area_num) as "玉公尺面積" from t_distribution where ad_area_code like '6103%' and flag ='1' and current_year ='2019';
select sum(area_num) as "其他面積" from t_distribution where ad_area_code like '6103%' and flag ='2' and current_year ='2019';
多邊形面積求和
acm中計算幾何是常考的乙個題型,這裡總結一下比較常見的多邊形面積求和問題 三角形的面積公式 s 0.5 ab ac 這裡以原點 0,0 為三角形的乙個頂點。向量叉乘 a b x1y2 x2y1 s x1y2 x2y1 2 多邊形就是多個三角形相加,因為是向量叉乘,因此自身帶有正負號,因此同樣適用於...
sql數值求和
實際 select sum shuliang sum danjia sum jine as 單價 sum danjia as 單價,sum jine as 金額 from ang dbo myshucai 1 對列求和可以使用聚合函式sum,例如 select sum 金額 as 合計 from 表...
sql分組求和
需求是 乙個月有多個發布額,現在要求按月統計發布額,例如 1月發布額 35900,2月發布額 2300 sql 語句如下 按月分組,求和 select dmonth,codename,sum iamount from 求出全部日期,發布額 select convert varchar 7 a.dre...