select
di_id as id,
di_ragione as ragione_sociale,
(select ba_nome from bandiere where ba_id = di_bandiera) as bandiera,
trim(concat(di_indirizzo_nocivico, ' ', di_civico)) as indirizzo,
right(concat('00000', di_cap), 5) as cap,
(select co_nome from pb_new.comuni where co_id = di_comune) as comune,
round(di_lat, 4) as lat, round(di_long, 4) as lng,
di_tel as telefono,
verde as benzina,
diesel as diesel,
gpl as gpl,
metano as metano
from distributori
where di_id > 1000 and di_lat > 0 and gpl = 1 or metano = 1
order by di_id
