[英]group by not working SQL- very basic
i did a few searches and i saw a few people try to do some kind of nested select statement in order to fix the issue. 我做了一些搜索,我看到一些人试图做一些嵌套的选择语句,以解决问题。 i did not understand it.
我不明白。
can someone help me please: 有人能帮助我吗:
the data is already sorted by provider name, each provider name is listed more than once based on various other columns in the table. 数据已按提供程序名称排序,每个提供程序名称根据表中的各种其他列列出多次。 however, when i do this, i do not get one line per provider name.
但是,当我这样做时,我没有为每个提供商名称获得一行。 instead the provider names repeat as if i am not using group by
相反,提供者名称重复,就好像我没有使用group by
here is the code: 这是代码:
create table moopnjsummary2 as
select mnj.ProviderName
from moopnj mnj
group by mnj.ProviderName
Do you want a list of mnj.ProviderName without repeats? 你想要一个没有重复的mnj.ProviderName列表吗? What is your final goal?
你的最终目标是什么?
You could also try SELECT DISTINCT 您也可以尝试SELECT DISTINCT
select mnj.ProviderName, count(*) as Providernamecount
from moopnj mnj
group by mnj.ProviderName
如果您要查找的是不同的ProviderNames,请尝试运行
SELECT DISTINCT moopnj.ProviderName FROM moopnj
This is a not a full answer to your question but if all you want is a list of provider names you should use: "Select DISTINCT mnj.ProviderName ...". 这不是您问题的完整答案,但如果您想要的是提供者名称列表,您应该使用:“选择DISTINCT mnj.ProviderName ...”。 That will eliminiate all duplicates.
这将消除所有重复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.