I need to conect two different query in one table
Basically treating each query as an individual column.
Error is
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
SQL
SELECT
(select sifra as cdr1
from popis_repromaterijal_roba as c with (nolock)
) AS Column1,
(select naziv as cdr2
from popis_repromaterijal_roba as c with (nolock)
) AS Column2,
(select sum(kolicina) as cdr3
from popis_repromaterijal_roba as c with (nolock)
) AS Column3,
(select sifra as success1
from mp_racun_roba as d with (nolock)
) AS Column4,
(select roba as success2
from mp_racun_roba as d with (nolock)
) AS Column5,
(select sum(kolicina) as success3
from mp_racun_roba as d with (nolock)
) AS Column6
Amit MohantyRank #112 · 20K reputationPosted Jul 14, 2023, 4:13 AM EDT
SELECT c.sifra AS cdr1, c.naziv AS cdr2, SUM(c.kolicina) AS cdr3, d.sifra AS success1, d.roba AS success2, SUM(d.kolicina) AS success3 FROM popis_repromaterijal_roba AS c WITH (NOLOCK) JOIN mp_racun_roba AS d WITH (NOLOCK) ON GROUP BY c.sifra, c.naziv, d.sifra, d.robaGoran BibicRank #993 · 2K reputationPosted Jul 17, 2023, 5:54 AM EDT
Code is ok, need update
Last column succes 3 need to be sum joined table, RESULT SUCCES 2 IS KAFA,KAFA,... NEED TO BE JUST 1 KAFA WTH SUCCES 3 SUMM