Skip to content

Instantly share code, notes, and snippets.

@vordan
Last active April 18, 2018 09:25
Show Gist options
  • Select an option

  • Save vordan/6915a18222c93c9847ec254f2d7fd7ba to your computer and use it in GitHub Desktop.

Select an option

Save vordan/6915a18222c93c9847ec254f2d7fd7ba to your computer and use it in GitHub Desktop.
Bara posledna cena za artikal vo tabela so ceni po datumi
-- ------------------------------------------------------------------
-- Bara posledna cena za artikal vo tabela so ceni po datumi
-- ------------------------------------------------------------------
select
temp_promet.*
from temp_promet
inner join (
select
artikal_id as artikal_id,
max(datum_ddo) as max_datum_ddo,
max(sifra) as max_sifra
from temp_promet
group by artikal_id
) as temp_promet_ceni on temp_promet_ceni.artikal_id = temp_promet.artikal_id and
temp_promet_ceni.max_datum_ddo = temp_promet.datum_ddo and
temp_promet_ceni.max_sifra = temp_promet.sifra
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment