Skip to content

Instantly share code, notes, and snippets.

@tomredsky
Created January 16, 2020 15:24
Show Gist options
  • Save tomredsky/ca499d47fe711664a695e7b7541d78b3 to your computer and use it in GitHub Desktop.
Save tomredsky/ca499d47fe711664a695e7b7541d78b3 to your computer and use it in GitHub Desktop.
select n.id,
ml.cod,
us.cod as ini,
mn.nam,
ct.num,
nm.licence_text as rights,
nm.price fee,
n.quote_total as total,
n.quote_currency
from notes n
join notes_media nm on n.id=nm.note_id
join ct on nm.media_id=ct.id
join ml on n.company_id=ml.id
join us on n.user_id=us.id
join mn on n.contact_id=mn.id
where n.id=?
@robrwo
Copy link

robrwo commented Jan 16, 2020

This needs

trunc(case when discount_is_percentage then discount else discount / quote_total * 100 end, 2) as discount_percentage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment