PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Jun 19, 2019 9:32 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Group By Field
PostPosted: Fri Mar 01, 2019 7:21 pm 
Offline

Joined: Fri Mar 01, 2019 3:03 pm
Posts: 2
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Group By Field
PostPosted: Sat Mar 02, 2019 9:24 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 474
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
 Post subject: Re: Group By Field
PostPosted: Mon Mar 11, 2019 12:19 am 
Offline

Joined: Fri Mar 01, 2019 3:03 pm
Posts: 2
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group