Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need to select multiple column from multiple tables sum and difference
 
Some help?


What I have tried:

select a.naziv as 'Naziv artikla', SUM (cast(a.kolicina as float)) as 'Nabavka', SUM (cast(b.kolicina as float)) as 'Prodaja', b.roba as  'Naziv artikla2'  
FROM (a.naziv, a.kolicina from ulazni_racun_roba_roba as a union all select a.naziv, a.kolicina from mp_ulazni_racun_ostalo_roba as a union all select b.roba, b.kolicina from mp_racun_roba as b union all select b.roba, b.kolicina from mp_faktura_roba as b) as alltables  
select (a.kolicina-b.kolicina) as UKUPNO  
group by naziv  
Posted
Comments
Mohibur Rashid 27-May-18 19:52pm    
Can you elaborate a bit more than this?
Goran Bibic 28-May-18 2:42am    
1)I need a.naziv, a.kolicina(a.naziv as 'Naziv artikla', SUM (cast(a.kolicina as float)) as 'Nabavka') from table ulazni_racun_roba_roba and mp_ulazni_racun_ostalo_roba (to be first and second datagrid column groub by naziv)

2) b.roba nad b.kolicina (SUM (cast(b.kolicina as float)) as 'Prodaja', b.roba as 'Naziv artikla2') from tables mp_racun_roba and mp_faktura_roba (third datagrid column) becose a.naziv=b.roba

3) DIFF( Column NABAVKA-Column PRODAJA ( in Column foor (TOTAL)))
Goran Bibic 29-May-18 1:53am    
Thank you
CHill60 30-May-18 13:56pm    
Some sample data and expected results are likely to help you get an answer to your question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900