问题描述
我在数据库中有数据
德国
印度
美国
中国
日本
非洲
印度(印度为第一行)
非洲(所有其他按字母顺序排列)
日本
美国
中国(最后一行是中国)
解决方法
您可以使用多种级别的排序:
order by col = 'India' desc,col = 'China',col
比率:在MySQL中,如果满足条件,则表达式col = <val>
返回1
,否则返回0
。因此col = 'India' desc
将印度放在首位,而col = 'China'
将中国放在最后。然后按照国家名称的常规排序打断领带。
在MySQL中,您可以执行以下操作:
library(ggplot2)
#Label
Lab <- expression(f(x) == paste(frac(1,sqrt(2 * pi * sigma^2))," ",e^{
frac(-(x - mu)^2,2 * sigma^2)
}))
#Code
ggplot(data.frame(x = c(-3,3)),aes(x))+
stat_function(fun = dnorm)+
annotate("text",label = Lab,x = -2,y = 0.3,color = "black",parse=T)
或使用order by (col = 'India') desc,(col = 'China') asc,col asc
表达式:
case