我有以下表格:
pkey - pval
one - dfgf
two - dg
three - asf
one - asarset
three - se
查询
select pkey,pval from dummy11 group by pkey,pval
返回以下输出..
pkey - pval
three - asf
one - asarset
three - se
one - dfgf
two - dg
为什么不是grouped by pkey,pval
?
我希望输出使用order by
select pkey,pval from dummy11 order by pkey,pval
但这与在这种情况下使用group by
不一样吗?
答案 0 :(得分:0)
Why is it not grouped by pkey,pval ?
答案:按照您的意见,您期待GROUP BY
无法做到的事情。
I want the output as how it comes by using order by
select pkey,pval from dummy11 order by pkey,pval
But isn't that the same thing as using group by in this case?
答:不,这不是一回事。 ORDER BY
对输出进行排序,GROUP BY
不对输出进行排序
GROUP BY
条款:
"groups a result into subsets that have matching values for one or more columns. "