a special query.... -
03-19-2010
, 08:09 AM
this is the SQL:
select ovt.progressivo as progressivo,
(case when opt.progressivo is null then ovt.situazione
when ovt.situazione='evaso' then 'pronto'
else 'in lavorazione'
end) as situazione,
ovt.*, tdo.descrizione tdo_descrizione
from ovt
inner join tdo on tdo.codice = ovt.tdo_codice
left join opt on opt.cms_codice=ovt.cms_codice and opt.tipologia=ovt.tipologia
where ovt.cli_codice = '00002043' and ovt.situazione = 'inserito'
order by ovt.tdo_codice, ovt.data_documento, ovt.numero_documento
I have 3 tables: ovt, tdo and opt
relations are
ovt -->tdo n-->1
ovt -->opt 1-->n
I need to have a row for every ovt rows with a field that change value if there is a link into opt table (field situazione)
but if I have more than 1 row into opt related to ovt I have back n ovt row instead one!
codebue fabio
p-soft |