WHERE BETWEEN Clause and Aggregates
-
Good afternoon,
I’ve just started using WP Data Access Premium in earnest and now migrating my existing internal reporting dashboard (written in .NET) to WP using your great plug-in – mainly to speed up ongoing development. However, I’m finding it tricky to implement (what seems to me a simple) particular requirement:
I have the following query which will just simply aggregate values between a date range from a view – like this:
SELECT
retailer_id, vendor_code, company_name,
SUM(num_sales) AS total_trans_count,
SUM(revenue) AS total_revenue
FROM vrpt_rev_daily_by_retailer_v1
WHERE trans_date BETWEEN <<DATE 1>> AND <<DATE 2>>
GROUP BY retailer_idSo effectively it’s summing a column for rows between a given range, for each retailer.
What I effectively want to do on the DATA PUBLISHER is just have a flat table with two dynamic filters (From Date and To Date) – which are used as the aggregate params and that’s it.
In my existing system, I just pass in the two date values and it builds the SQL (as above) and fires it off – but I’m struggling to see how this can be achieved using WP Data Access. Date ranges are a common theme in reporting systems – so some pointers would be great to achieve this. In summary:
1) Can you specify aggregate fields (e.g. SUM() ) ?
2) Can two filter values be passed back in as a BETWEEN clause ?Or do I need to drop into code to do this – which is what I’m trying to avoid by using this tool?
Cheers
Matt
- The topic ‘WHERE BETWEEN Clause and Aggregates’ is closed to new replies.