Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
select
coalesce(sklypai.Sklypo_adresas, 'Be adreso') as adresas,
coalesce(sklypu_sumos.Moketojo_pavadinimas, 'Be pavadinimo') as Nuomininkas,
coalesce(sklypai.Naudojimo_pradzia, 'Nenurodyta') as Naudojimo_pradzia,
coalesce(sklypai.Naudojimo_pabaiga, 'Nenurodyta') as Naudojimo_pabaiga,
sklypai.Plotas*sklypai.Skaitiklis / sklypai.Vardiklis as Nuomojamas_plotas,
coalesce((sklypu_sumos.Suma) / (datediff(
least(
curdate(),
coalesce(sklypai.Naudojimo_pabaiga, curdate())),
sklypai.Naudojimo_pradzia)
/365) / sklypai.Plotas, 0) as kaina,
sklypai.lat,
sklypai.lon
from sklypai
join sklypu_sumos on sklypu_sumos.Moketojo_ID=sklypai.Moketojo_ID
where sklypai.lat is not null
group by sklypai.Moketojo_ID
having count(*)=1
order by kaina desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.