本文介绍了来自多个表SQL的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有来自多个表和工作的代码,
我需要从另一个表添加另一个列
CONECTION IS NAME(名称)在代码是naziv),数量(代码kolicina中的名称)
我尝试过:
I HAVE CODE FROM MULTIPLE TABLES AND WORK,
I NEED TO ADD ANOTEHER COLUMN FROM ANOTHER TABLE
CONECTION IS NAME ( name in code is "naziv"), quantity (name in code "kolicina")
What I have tried:
select x1.Naziv, x1.Nabavka, (ISNULL(x2.Prodaja,0)) as Prodaja, x1.Nabavka-(ISNULL(x2.Prodaja,0)) as 'Stanje' from (select naziv, sum(kolicina) as Nabavka from
(select naziv as naziv, convert(float, kolicina) as kolicina from mp_ulazni_racun_roba_roba union all select naziv as naziv, convert(float, kolicina) as kolicina from mp_ulazni_racun_ostalo_roba ) a
group by naziv) x1 left join(select roba, sum(kolicina) as Prodaja from
(select roba, convert(float, kolicina) as kolicina from mp_racun_roba union all select roba, convert(float, kolicina) as kolicina from mp_faktura_roba ) b
group by roba) x2 on x1.naziv = x2.roba
另一个表格栏目
ANOTHER TABLE COLUMN
select minimalna_dozvoljena_kolicina from dbo.roba_usluge
推荐答案
这篇关于来自多个表SQL的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!