How does one "SUM" and "GROUP BY"?

From semantic-mediawiki.org

Hi all,

I'm trying to select a set of data and do a "SUM" and "GROUP BY" on the result.

I have the following ask:

{{#ask:[[Category:Knowledge Transfer Log]]
|?Date
|?Total
|format=broadtable
|sort=Date
}}

Which results in this:

                Date            Total 
Item 0004 	29 April 2013 	5 	
Item 0005 	6 May 2013 	2 	
Item 0006 	10 May 2013 	3 	
Item 0007 	14 May 2013 	16 	
Item 0003 	14 May 2013 	17 	
Item 0008 	15 May 2013 	10 	

As you can see, Item 7 and Item 3 are both on the 14th May, however I'd like one record, summed, with a total of 33 instead of two separate records.

I've read up about the Sum format but that adds all rows together. I've also seen this trick of getting unique values, but it won't work with #ask.

Any help would be greatly appreciated.

09:10, 19 May 2013

Hi,

Has no-one solved this problem?

Cheers Walter

14:23, 8 August 2013

I'm afraid, there's no way to GROUP or SELECT DISTINCT. SMW selects pages (and internal objects). You can only use nested queries: first select dates (and you have to use Array extension or Lua to make selection distinct), format the selection with a template and include a query for Total into the template. Or use Lua from the beginning.

03:04, 18 August 2014