USE `eldars_trenesanas_eksamenam_1`;

CREATE OR REPLACE VIEW `v_janvara_akts` AS
SELECT
    dn.nr               AS `Darba nr`,
    dv.nosaukums        AS `Pozīcija`,
    m.nosaukums         AS `merv`,
    dv.cena_bez_pvn     AS `cena`,
    ap.daudzums         AS `Daudzums`,
    ap.kopa_bez_pvn     AS `Kopā`,
    ap.kopa_ar_pvn      AS `Kopā ar PVN`
FROM akts_pozicijas ap
JOIN darbu_veidi dv ON dv.id = ap.darba_veids_id
JOIN darba_nri   dn ON dn.id = dv.darba_nr_id
JOIN mervienibas m  ON m.id  = dv.mervieniba_id
WHERE ap.akts_id = 1
ORDER BY dn.nr;

SELECT * FROM v_janvara_akts;
