Goran Bibic

Goran Bibic

  • 695
  • 2.3k
  • 59.5k

Insert into select from two tables values an instert in anot

May 25 2019 8:26 AM
Some help?
Error in ms sql
Msg 147, Level 15, State 1, Line 2
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
  1. INSERT INTO dbo.trebovnica(redni_broj, datum, radni_nalog, sifra , naziv, proizvodjac  ,jedinica_mjere, kolicina, magacin)  
  2. Select redni_broj, (select datum_otvaranja from dbo.radni_nalog_lista WHERE id = (select max(id) from dbo.radni_nalog_lista)), (select broj_rn from dbo.radni_nalog_lista WHERE id=MAX(id)),   
  3. sifra, naziv, proizvodjac, jedinica_mjere, kolicina, 'Magacin proizvodnja Celinac' from dbo.normativi_roba where id_fakture=(select id from normativi_lista where id=2) 

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (1)