Essentially what im trying to get is the increase in views of a property on a property website after running an advertising campaign. Every view is equal to a row in the Views Table. Assuming the advertising campaign ran the month of Jan 2014.
I can run 2 seperate Queries 1) to get the Count of january 2) To get the count of February
Query 1 - Views For January
SELECT COUNT(Views.ViewId) AS 'January Munster Views'
FROM Views
INNER JOIN Property
ON Views.PropertyId=Property.PropertyId
WHERE Views.ViewsDate LIKE '2015-01-%'
AND Property.PropertyPrice BETWEEN "800" AND "1000"
AND (Property.PropertyCounty='Co Waterford' OR Property.PropertyCounty='Co Cork' OR Property.PropertyCounty='Co Clare'
OR Property.PropertyCounty='Co Kerry' OR Property.PropertyCounty='Co Tipperary' OR Property.PropertyCounty='Co Limerick' );
Result = 103
Query 2 - Views For February
SELECT COUNT(Views.ViewId) AS 'February Munster Views'
FROM Views
INNER JOIN Property
ON Views.PropertyId=Property.PropertyId
WHERE Views.ViewsDate LIKE '2015-02-%'
AND Property.PropertyPrice BETWEEN "800" AND "1000"
AND (Property.PropertyCounty='Co Waterford' OR Property.PropertyCounty='Co Cork' OR Property.PropertyCounty='Co Clare'
OR Property.PropertyCounty='Co Kerry' OR Property.PropertyCounty='Co Tipperary' OR Property.PropertyCounty='Co Limerick' );
Result = 274
Is there any way to just return 171 as a result with a column title of "Increase" ?
I could of course just do the work in Java or PHP but id like to know if its possible just using SQL Statement?
Thanks