I'm trying to composite assay geology data, this must be done by each lithology from drill-hole, so I have two tables assay and geology.
In assay table I have hole number, From, To and P2O5, and in the geology table I have hole number, Ore Zone.
I select hole number, ore zone from the geology and calculate the average weight with assay P2O5, From and To (difference will give me the length) columns.
SELECT
UDEF_GEOLOGY.HOLE_NUMBER,
UDEF_GEOLOGY.ore_zone,
MIN(UDEF_GEOLOGY.depth_from) AS 'From',
MAX(UDEF_GEOLOGY.depth_to) AS 'To',
SUM(CAST(HOLE_ASSAY_SAMPLE.P2O5_per_MEXRF26K AS FLOAT)* CAST((HOLE_ASSAY_SAMPLE.depth_to-HOLE_ASSAY_SAMPLE.depth_from) AS FLOAT))/ SUM(CAST((HOLE_ASSAY_SAMPLE.depth_to-HOLE_ASSAY_SAMPLE.depth_from) AS FLOAT)) AS 'P2O5_POND'
FROM
udef_geology
INNER JOIN HOLE_ASSAY_SAMPLE ON
UDEF_GEOLOGY.HOLE_NUMBER = HOLE_ASSAY_SAMPLE.HOLE_NUMBER
GROUP BY
UDEF_GEOLOGY.HOLE_NUMBER,
UDEF_GEOLOGY.ore_zone
ORDER BY
UDEF_GEOLOGY.HOLE_NUMBER,
MIN(UDEF_GEOLOGY.DEPTH_FROM)
I expect to get the pound result for each ore zone and hole number instead this sentence gives me the pound of all hole numbers.