Need more, need help now?
- - - - - - - - - - - - - - - - - - pay-as-you-go support - no contract - tenth of an hour billing - expert help - fast service - no call queues
Need integration?
- - - - - - - - - - - - - - - - - - with your shipping system - website - invoicing system - crm - cms - manufacturing - order import - back to back orders..
Need a report?
- - - - - - - - - - - - - - - - - - Excel reporting that pulls data from Sage - custom layouts - layouts that change adapt to your brands and/or for drop shipping.
Want web hosting?
- - - - - - - - - - - - - - - - - - Your own domain name - email - a shop - wordpress - woo commerce - ticket systems - help desks - forums - portals

Joining on subqueries

Report design issues and solutions.
Post Reply
taxrebel
User
User
Posts: 7
Joined: 11 Nov 2012, 10:10
Sage Version: v2013 19 UK/Europe/Africa

Joining on subqueries

Post by taxrebel » 11 Nov 2012, 10:35

I need to add the date of the last communication with a customer to an aged debtors report. Of course if I use a regular join to the contact_history table for this I end up duplicating the financial records by the number of communication events.
Using regular SQL this could be done with a subquery; something like:
INNER JOIN (SELECT refn, max(contact_date) FROM contact_history GROUP BY refn) last ON sales_ledger.account_ref = last.refn
Is it possible to achieve something similar in Report Designer?

User avatar
brucedenney
Site Admin
Site Admin
Posts: 4631
Joined: 28 Feb 2006, 09:56
Sage Version: v28 UK/Europe/Africa

Re: Joining on subqueries

Post by brucedenney » 14 Nov 2012, 18:46

Yes and No it is possible but...

You have to accept that it will return a huge amount of data, if you make sure the data is sorted by contact date, then create a group for the contact, hide all the details and only show the group footer, in the group footer when you refer to the contact, it will be the last contact it saw, which in turn id the last dated contact.

Nasty and inefficient but it will work.
For just about anything Sage :- Discount subscriptions, pay-as-you-go support, application integration, reports, layouts, linked excel spreadsheets, analysis or any other help making life with sage easier/less time consuming Contact me.

taxrebel
User
User
Posts: 7
Joined: 11 Nov 2012, 10:10
Sage Version: v2013 19 UK/Europe/Africa

Re: Joining on subqueries

Post by taxrebel » 15 Nov 2012, 08:18

Yes, it does. As you say it is horribly inefficient though. It's a shame there isn't more user control over the underlying SQL.

User avatar
brucedenney
Site Admin
Site Admin
Posts: 4631
Joined: 28 Feb 2006, 09:56
Sage Version: v28 UK/Europe/Africa

Re: Joining on subqueries

Post by brucedenney » 15 Nov 2012, 11:09

The fundamental problem is that the database is not an sql database it is a series of flat files with indexes.
For just about anything Sage :- Discount subscriptions, pay-as-you-go support, application integration, reports, layouts, linked excel spreadsheets, analysis or any other help making life with sage easier/less time consuming Contact me.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests