SQL问题,请尽可能帮助。 [英] SQL problem, help if possible please.

查看:73
本文介绍了SQL问题,请尽可能帮助。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我猜这对你们来说很简单但是我是sql的新手,我不确定如何创建这个查询(我必须在SQL中做)。


我想在一个查询中显示哪个供应商销售所有种类的植物。例如,我希望查询显示结果如下:


供应商种类


PlantCO植物,树,花


(连续不连续,可能是每个物种分开排列)。


我试过计算一​​下,计算出售所有物种的供应商数量然而,它并没有太好用:


SELECT DISTINCT LEVERANC.LEV_NAAM,Count(PLANTEN.PLANTNAAM)作为PLANTNAAM
来自PLANTEN INNER的
在LETAN.ART_CODE = OFFERTES.ART_CO

GROUP BY LEVERANC.LEV_NAAM;


(JOVER上,LEVERANC INNER JOIN OFFERT LEVERANC.LEV_CODE = OFFERTES.LEV_CODE)对不起,这是荷兰的数据,plantnaam是工厂,leveranc是供应商)。


我希望这是足够的信息,如果有人能给我提供建议或解决方案,我会非常感激。谢谢你:)

Hi,

I am guessing this is something simple to you guys however I am new to sql and am unsure how to create this query (I must do it in SQL).

I am wanting to show in one query which supplier sells all species of plants. So for instance I want the query to display the results like so:

Supplier Species

PlantCO Plant, Tree, flower

(not neccessarily in a row, could be every species in separate row).

I tried a count to count the number of suppliers which sell all species, however, it didn''t work out too good:

SELECT DISTINCT LEVERANC.LEV_NAAM, Count(PLANTEN.PLANTNAAM) AS PLANTNAAM
FROM PLANTEN INNER JOIN (LEVERANC INNER JOIN OFFERTES ON LEVERANC.LEV_CODE = OFFERTES.LEV_CODE) ON PLANTEN.ART_CODE = OFFERTES.ART_CO
GROUP BY LEVERANC.LEV_NAAM;

(sorry it is Dutch data, plantnaam being the plant and leveranc being the supplier).

I hope this is enough information and if anybody can provide me with advice or a solution I would appreciate it a lot. Thankyou :)

推荐答案

如果我理解正确你可以使用以下SQL语句。


SELECT< Supplier> ; FROM< table_name>

WHERE<列名> IS NOT NULL,<列名> IS NOT NULL ....等等...这假设每个Specie都列在一个单独的列中。

希望这会有所帮助..

If I understand you correctly you can prob use the following SQL statement.

SELECT <Supplier> FROM <table_name>
WHERE <Column Name> IS NOT NULL, <Column Name> IS NOT NULL....and so on...This is assuming that each Specie is listed in a separate column.
Hope this helps..





我猜这对你们来说很简单但是我是sql的新手,我不确定如何创建这个查询(我必须在SQL中做)。


我想在一个查询中显示哪个供应商销售所有种类的植物。例如,我希望查询显示结果如下:


供应商种类


PlantCO植物,树,花


(连续不连续,可能是每个物种分开排列)。


我试过计算一​​下,计算出售所有物种的供应商数量然而,它并没有太好用:


SELECT DISTINCT LEVERANC.LEV_NAAM,Count(PLANTEN.PLANTNAAM)作为PLANTNAAM
来自PLANTEN INNER的
在LETAN.ART_CODE = OFFERTES.ART_CO

GROUP BY LEVERANC.LEV_NAAM;


(JOVER上,LEVERANC INNER JOIN OFFERT LEVERANC.LEV_CODE = OFFERTES.LEV_CODE)对不起,这是荷兰的数据,plantnaam是工厂,leveranc是供应商)。


我希望这是足够的信息,如果有人能给我提供建议或解决方案,我会非常感激。谢谢你:)
Hi,

I am guessing this is something simple to you guys however I am new to sql and am unsure how to create this query (I must do it in SQL).

I am wanting to show in one query which supplier sells all species of plants. So for instance I want the query to display the results like so:

Supplier Species

PlantCO Plant, Tree, flower

(not neccessarily in a row, could be every species in separate row).

I tried a count to count the number of suppliers which sell all species, however, it didn''t work out too good:

SELECT DISTINCT LEVERANC.LEV_NAAM, Count(PLANTEN.PLANTNAAM) AS PLANTNAAM
FROM PLANTEN INNER JOIN (LEVERANC INNER JOIN OFFERTES ON LEVERANC.LEV_CODE = OFFERTES.LEV_CODE) ON PLANTEN.ART_CODE = OFFERTES.ART_CO
GROUP BY LEVERANC.LEV_NAAM;

(sorry it is Dutch data, plantnaam being the plant and leveranc being the supplier).

I hope this is enough information and if anybody can provide me with advice or a solution I would appreciate it a lot. Thankyou :)


如果答案没有解决你的问题,也许你可以发布你正在使用的数据布局。

你有几张桌子?

这些桌子中有哪些字段?

这些桌子在逻辑上是如何连接的?

Ansers当人们掌握相关信息时,会更容易获得。
If that answer doesn''t solve your problem, perhaps you could post the data layout you''re working with.
What tables do you have?
Which fields are in those tables?
How are the tables logically joined?
Ansers are much easier to come by when people have the info available.


它没有解决问题,但也许只是我!


为了帮助澄清一点。我要找到销售所有物种(soort)植物(plantnaam)的供应商(leveranc)。实体和关系如下:


Planten- ART_CODE,PLANTNAAM,SOORT

OFFERTES- LEV_CODE,ART_CO_LEV,ART_CO(链接planten和leveranc)。

leveranc- LEV_CODE,LEV_NAAM,ADRES,WOONPLAATS(CITY)

加入VIA :( leveranc.lev_code = offertes.lev_code and planten.art_code = offertes.art_co_lev)。


我只需要显示供应商名称(LEV_NAAM)和植物种类(SOORT)。因此,我需要使用leveranc表和planten表(使用offertes作为链接)。


如果这也有帮助的话,有11个lev_naam(供应商)和10个不同的物种(soort)。


我希望我现在更清楚了=)
It didn''t solve the problem, but perhaps it is just me!

To help clarify a bit better. I am to find the supplier (leveranc) who sells all species (soort) of plants (plantnaam). The entities and relationships are as follows:

Planten- ART_CODE, PLANTNAAM, SOORT
OFFERTES- LEV_CODE, ART_CO_LEV, ART_CO (being the table which links planten and leveranc).
leveranc- LEV_CODE, LEV_NAAM, ADRES, WOONPLAATS (CITY)

JOINED VIA: (leveranc.lev_code=offertes.lev_code and planten.art_code= offertes.art_co_lev).

I need to show the supplier name (LEV_NAAM) and the species of the plants(SOORT) only. Thus I need to use both the leveranc tables and the planten tables (using offertes as the link).

There are 11 lev_naam (suppliers) and 10 different species (soort) if this also helps.

I hope I have made it all clearer now =)


这篇关于SQL问题,请尽可能帮助。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆