I am very new when it comes to using SQL and what I am attempting to do is select the waterUsage and electrcityUsage using only the month and year and select the waterUsage and electrcityUsage from the previous year.
However I cannot seem to figure out the appropriate way to use dates in order to make this work.
Table: monthlyBill
1. billingDate 01-SEP-15
2. waterUsage varchar(256)
3. electrcityUsage varchar(256)
4. accountNumber varchar(256)
select electrcityUsage, waterUsage
from monthlyBill
where accountNumber ='211'
and billingDate = '12-12' /*,month, year*/
or
select electrcityUsage, waterUsage
from monthlyBill
where accountNumber ='211'
and billingDate = DATEADD(year,-1,GETDATE()); /*,previous year*/
dateadd()orgetdate()