I am displaying a property from the following table given below. Now what i have to do is, find the property in the same location(suppose my property is located in sec-19, match for sec-19 and if none of them found there then search for the entire city) with the following condition that it should be posted 10 days back or if none is posted 10 days back than take result on the basis of 30 days back.
I have the following table(Properties) mentioned below:
Now what i want to retrieve from this table is the 'Propertyid' and 'Average Price' of those properties whose listing time is less than 10 days if none of them are less than 10 days then return the result for less than 30 days.
Can anybody help me solving this problem. Thanks in advance.
Or just Any body can answer me without the Location match.
I need to calculate 'Average Price' from the properties posted 10 days ago, if there is no property posted 10 days ago then take it as 30 days ago. Something like this:
Select AVG(Price) As Average_Price from Properties where (DATEDIFF(day,listingtime,getdate())<30 or DATEDIFF(day,listingtime,getdate())<10)
But here i am getting only one Field 'Average Price' and here also i am not putting the check to filter whether it has been posted 10 days ago or 30 days ago. Knidly Recheck and try to solve my problem. Thanks in Advance.