select distinct
    --s.Nume as NumeSal,
    --s.Prenume as PrenumeSal,
    s.Nume || ' ' || s.Prenume as NumeSal,
    cast(NumarContract as integer) as NrContr,
    date(DataContract) as DataContract,
    date(DataInceputContract) as DataInceput,
    --s.AuditTimestamp,
    --s.TipActualizare,
    Salariu,
    --printf('%.f', round(Salariu * 1.0225)) as Cost,
    round(Salariu * 1.0225) as Cost,
    date(DataConsemnare) as DataConsemn,
    ifnull(Detalii, '') as Detalii,
    cor.Cod as CodCor,
    cor.Nume as NumeCor,
    Replace(
        Replace(TipContract,
        '0', 'standard'),
        '5', 'clauzaTelemunca') as TipContract,
    Replace(
        Replace(TipDurata,
        '0', 'nedeterminata'),
        '1', 'determinata') as TipDurata,
    Replace(
        Replace(TipNorma,
        '0', 'NormaIntreaga'),
        '1', 'TimpPartial') as TipNorma,
    ifnull(
        TimpMuncaDurata, 8) as Ore,
    Replace(
        Replace(ifnull(TimpMuncaIntervalTimp, ''),
	        '0', 'ore/zi'),
	        '1', 'ore/saptamana') as IntervTimp,
    --StareCurentaId,
    ifnull(date(inc.DataIncetare), '') as DataIncetare,
    Replace(
        Replace(
            Replace(ifnull(inc.TemeiLegal, ''),
            '0', 'acordul partilor'),
            '18', 'demisie'),
            '17', 'demisie')
            as TemeiLegal
from
    Contract ctr
left join Salariat s on ctr.SalariatId = s.Id
left join Cor cor on ctr.CorId = cor.Id
left join ContractStareIncetare inc on ctr.StareCurentaId = inc.ContractStareId
--where inc.DataIncetare is null
order by s.Nume