Skip to content

Instantly share code, notes, and snippets.

@anandpdoshi
Created January 4, 2013 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anandpdoshi/4450482 to your computer and use it in GitHub Desktop.
Save anandpdoshi/4450482 to your computer and use it in GitHub Desktop.
Example: How to add a Total row in Query Report of ERPNext
select
item.name as "ID:Link/Item:120",
item.item_name as "Item Name::120",
item_price.price_list_name as "Price List::80",
item_price.ref_currency as "Currency::40",
item_price.ref_rate as "Rate:Currency:80",
item.description as "Description::160",
item.item_group as "Item Group:Link/Item Group:100",
item.brand as "Brand::100"
from `tabItem` item, `tabItem Price` item_price
where
item_price.parent = item.name
union
select
"" as "ID::120",
"Total" as "Item Name::120",
"" as "Price List::80",
"" as "Currency::40",
sum(item_price.ref_rate) as "Rate:Currency:80",
"" as "Description::160",
"" as "Item Group:Link/Item Group:100",
"" as "Brand::100"
from `tabItem` item, `tabItem Price` item_price
where
item_price.parent = item.name
@anandpdoshi
Copy link
Author

resulting screenshot:

Total in Query Report

@khaludi2
Copy link

khaludi2 commented Jul 9, 2015

This is very good example, but when filtering by any field the total will not show up accordingly. seems short coming? How to show it up?

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