SELECT month,Avg(rain_fall) FROM rain_fall WHERE
STR_TO_DATE( CONCAT('01','-',month,'-',year) , '%d-%b-%Y')
between
STR_TO_DATE('01-Jan-1991','%d-%b-%Y') and
STR_TO_DATE('01-Dec-1993','%d-%b-%Y')
group by month
order by MONTH(STR_TO_DATE( CONCAT('01','-',month,'-',year) , '%d-%b-%Y'))
UNION
SELECT month,Avg(data_value) FROM temprature_data WHERE
STR_TO_DATE( CONCAT('01','-',month,'-',year) , '%d-%b-%Y')
between
STR_TO_DATE('01-Jan-1991','%d-%b-%Y') and
STR_TO_DATE('01-Dec-1993','%d-%b-%Y')
group by month
order by MONTH(STR_TO_DATE( CONCAT('01','-',month,'-',year) , '%d-%b-%Y')) ;
以上是我的SQL查询。我希望得到一年中temprature_data table和rain_fall表中所有月份的平均值。
收到错误讯息:
#1221 - UNION和ORDER BY的使用不正确
答案 0 :(得分:1)
在每个void HandleManToggled(object sender, Xamarin.Forms.ToggledEventArgs e)
{
var s = sender as Switch;
if (s.IsToggled)
WomanGenderSwitch.IsToggled = false;
else
WomanGenderSwitch.IsToggled = false;
}
void HandleWomanToggled(object sender, Xamarin.Forms.ToggledEventArgs e)
{
var s = sender as Switch;
if (s.IsToggled)
ManGenderSwitch.IsToggled = false;
else
ManGenderSwitch.IsToggled = false;
}
查询和select
上使用括号:
P.S。:UNION ALL
是保留字。如果在这里,您使用的是列名,请尝试将其更改为其他内容,以免在以后的查询中发生冲突。 Check this list of reserved words in MySQL
month