I have a SQL statement (i have a report in visual studio that creates a dataset) and calls this
sqlstmt1
this is based on a view (shown below) but the code above basically returns a row each for each ward name and the total number of calls raised for that ward.
This works great.
i have another dataset from this sql statement (shown below) which returns, as above, a row for each ward with a grand total of uprns's within that ward this time.
I'd like to get a percentage, dividing the total number of calls raised for the ward (as above sqlstmt1) by the total number of uprn's in that ward. (below sqlstmt2)
does that make sense ?
thanks for any help....................
sqlstmt2
sqlstmt1
Code:
SELECT WARD_NAME, COUNT(*) AS CustomerCount, WARD_ID
FROM dbo.vwLPGWards
GROUP BY WARD_NAME, WARD_ID
ORDER BY COUNT(*), WARD_NAME, WARD_ID
this is based on a view (shown below) but the code above basically returns a row each for each ward name and the total number of calls raised for that ward.
This works great.
Code:
SELECT DISTINCT
TOP 100 PERCENT WARDS.WARD_NAME, ADDR.CUSTOMER,
WARDS.WARD_ID FROM WARDS INNER JOIN
WARDUPRN ON WARDS.WARD_ID = WARDUPRN.WARD_ID INNER JOIN
CADTABLE ON WARDUPRN.UPRN = CADTABLE.UPRN INNER JOIN
ADDR ON CADTABLE.OSADDESSP = ADDR.UPRN
WHERE (ADDR.EDATE IS NULL)
ORDER BY ADDR.CUSTOMER
i have another dataset from this sql statement (shown below) which returns, as above, a row for each ward with a grand total of uprns's within that ward this time.
I'd like to get a percentage, dividing the total number of calls raised for the ward (as above sqlstmt1) by the total number of uprn's in that ward. (below sqlstmt2)
does that make sense ?
thanks for any help....................
sqlstmt2
Code:
SELECT WARDS.WARD_NAME, Count(WARDS.WARD_NAME) as WardCount, WARDS.WARD_ID FROM WARDUPRN INNER JOIN
WARDS ON crmuser.CTS_WARD_UPRN.WARD_ID = WARDS.WARD_ID
GROUP BY WARDS.WARD_NAME, WARDS.WARD_ID
ORDER BY COUNT(WARDS.WARD_NAME), WARDS.WARD_NAME