{% set total_unpaid=frappe.db.sql("""
select sum(debit_in_account_currency) - sum(credit_in_account_currency)
from `tabGL Entry`
where party_type = 'Customer' and party= 'Shree Ganesh Ji'""") %}
Tried but no luck.
Showing below error.
UndefinedError: 'dict object' has no attribute 'sql'
Why do you need to make it in Jinja? It is frustrating. If you are using Web Forms on www folder, create another .py file with the same name as html. Code there and pass the values in Jinja Templates.