PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Group By Field
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3921
Page 1 of 1

Author:  JCorD [ Fri Mar 01, 2019 7:21 pm ]
Post subject:  Group By Field

I am wondering if it is possible to Group By a field in PDFSharp/MigraDoc?

Currently, I have my report working just fine however I would like the Category to print 1 time followed by the items for that category, print the next category and it's associated items, etc.

Author:  TH-Soft [ Sat Mar 02, 2019 9:24 am ]
Post subject:  Re: Group By Field

JCorD wrote:
I am wondering if it is possible to Group By a field in PDFSharp/MigraDoc?
PDFsharp and MigraDoc show the data as you feed it.
Simply group the data before feeding it into PDFsharp or MigraDoc.

Author:  JCorD [ Mon Mar 11, 2019 12:19 am ]
Post subject:  Re: Group By Field

TH-Soft wrote:
PDFsharp and MigraDoc show the data as you feed it.
Simply group the data before feeding it into PDFsharp or MigraDoc.


Thank you for the reply! I have to admit it left me scratching my head for a moment, but it got me thinking about the query. To make it work as expected I run a query to grab the first item of each category by the lowest ID number creating a temporary table:

Code:
SELECT
    ID,
    item,
    category
FROM
    Table
WHERE
    ID IN (SELECT min(ID) FROM Table GROUP BY category)


I then Joined the temporary table and used it in a CASE statement to manipulate the output.

Code:
(CASE WHEN t1.item = _tmp.item THEN category ELSE '' END) AS Category

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/