Hi Chris,
Try this:
SELECT
NVL(attribute_value.attrib_value_name, 'No Tree Height Attribute set against Feature') tree_height,
COUNT(job.job_number) no_of_jobs
FROM
job
JOIN feature ON
job.site_code = feature.site_code AND
job.plot_number = feature.plot_number
left JOIN (
feat_attrib_type
JOIN attribute_value ON
feat_attrib_type.attrib_type_code = attribute_value.attrib_type_code AND
feat_attrib_type.attrib_value_code = attribute_value.attrib_value_code
JOIN attribute_type ON
attribute_type.attrib_type_code = attribute_value.attrib_type_code
)
ON
feature.site_code = feat_attrib_type.site_code AND
feature.plot_number = feat_attrib_type.plot_number AND
feat_attrib_type.attrib_type_code = 'T001'
JOIN feature_type ON
feature.feature_type_code = feature_type.feature_type_code
WHERE
feature_type.feature_group_code = 'T001' AND
job.actual_comp_date BETWEEN TO_DATE('01-APR-2019', 'DD-MON-YYYY') AND TO_DATE('31-MAR-2020', 'DD-MON-YYYY')
GROUP BY
attribute_value.attrib_value_name;
It assumes that,
- the Actual Completion date falls between the 1st Apr 2019 and 31st March 2020
- Features that do not have the 'T001 - Tree Height' Attribute Type associated with them are also to be considered
- Features that belong to the Feature Group 'T001 - Arboriculture' are deemed to all be Trees
Hope this helps.
Kind regards,
Steve
------------------------------
Steve Bish
Senior Software Support Analyst
Confirm
------------------------------
Original Message:
Sent: 08-19-2020 14:13
From: Chris Mackenzie-Smith
Subject: SQL query - can anyone help with a tree data report?
Hi everyone!
This is a massive longshot but has anyone ever created an SQL report in Confirm to generate the following data?
'The number of tree work tasks (I think they mean jobs rather than individual SOR items) undertaken in the 19/20 financial year split up by the tree height category (a feature attribute).'
If anyone knows the SQL for this which I could copy and paste I'd be extremely grateful.
Many thanks!
Chris
Tree Team
Royal Borough of Windsor and Maidenhead
------------------------------
Chris Mackenzie-Smith
THE ROYAL BOROUGH OF WINDSOR AND MAIDENHEAD COUNCIL
MAIDENHEAD
------------------------------