使用单个表insqlserver中的leftouterjoin. [英] using leftouterjoin from single table insqlserver.

查看:89
本文介绍了使用单个表insqlserver中的leftouterjoin.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有我有一个要求,我需要从单个表中获取值,该表具有3个列id,name,id = 1的值,我有4个名称(a,b,c,d)并具有值因为它像a一样有10个值,b和c和d都有10个值,并且id = 2我只有3个名字(a,b,c)每个都有10个值,现在我的要求是得到这样产生的结果

HI all i had a requirement where i need to get a values from single table , the table has 3 colms id,name,value for id=1 i have 4 names (a,b,c,d) and has values for it like for a there are 10 values for b 10 values same for c and d, and for id=2 i have only 3 names (a,b,c) with 10 values for each , now my requirement here is to get the result in this way

name  id       values(sum(values))        id          values<br />
<br />
a       1             15                   2            187<br />
b       1              20                  2            168<br />
c       1             18                   2            132<br />
d       1             31                   Null         Null



我尝试了左外部联接和内联查询,但是我失败了,是否由于相同的表值和组而失败了?我不确定是否有任何方法可以实现它,请指导我谢谢



i tried left outer join and inline query but i failed ,are they failing beacuse of same table values and group by i am not sure about it is there any way i can achieve it please guide me thanks

推荐答案

尝试向我们展示您尝试过的一些实际查询,我们可能会提供帮助.我们不是在这里简单地为您做功课.我们在这里为您解决已解决的问题.
Try showing us some of the actual query you have tried and we can possibly help. We are not here to simple do your homework for you. We''re here to help you with problems that you have getting it done.


这篇关于使用单个表insqlserver中的leftouterjoin.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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