Destin Beachfront Condos

SQL: SELECT TOP 1000 AS Rental_id, Rental.CustomerId AS Rental_CustomerId, Rental.RentalTypeId AS Rental_RentalTypeId, Rental.ContentId AS Rental_ContentId, Rental.AddressId AS Rental_AddressId, Rental.SoftwareId AS Rental_SoftwareId, Rental.StaffId AS Rental_StaffId, Rental.Title AS Rental_Title, Rental.Teaser AS Rental_Teaser, Rental.Bedrooms AS Rental_Bedrooms, Rental.Bathrooms AS Rental_Bathrooms, Rental.Sleeps AS Rental_Sleeps, Rental.Code AS Rental_Code, Rental.SoftwareCode AS Rental_SoftwareCode, Rental.UrlTitle AS Rental_UrlTitle, Rental.Priority AS Rental_Priority, Rental.EnabledFlag AS Rental_EnabledFlag, Rental.DateCreated AS Rental_DateCreated, Rental.DateUpdated AS Rental_DateUpdated, Rental.DateDisplayed AS Rental_DateDisplayed, AS Address_id, Address.AddressTypeId AS Address_AddressTypeId, Address.Address1 AS Address_Address1, Address.Address2 AS Address_Address2, Address.City AS Address_City, Address.StateId AS Address_StateId, Address.CountryId AS Address_CountryId, Address.ZipCode AS Address_ZipCode, Address.Latitude AS Address_Latitude, Address.Longitude AS Address_Longitude, Address.DateCreated AS Address_DateCreated, Address.DateUpdated AS Address_DateUpdated, AS AddressType_id, AddressType.AddressType AS AddressType_AddressType, AS Content_id, Content.LanguageId AS Content_LanguageId, Content.HtmlContent AS Content_HtmlContent, Content.PageTitle AS Content_PageTitle, Content.MetaDesc AS Content_MetaDesc, Content.MetaKeywords AS Content_MetaKeywords, Content.DateCreated AS Content_DateCreated, Content.DateUpdated AS Content_DateUpdated, AS Customer_id, Customer.AccountId AS Customer_AccountId, Customer.AddressId AS Customer_AddressId, Customer.Company AS Customer_Company, Customer.LegalName AS Customer_LegalName, Customer.Email AS Customer_Email, Customer.EnabledFlag AS Customer_EnabledFlag, Customer.ApiKey AS Customer_ApiKey, Customer.DateCreated AS Customer_DateCreated, Customer.DateUpdated AS Customer_DateUpdated, AS RentalType_id, RentalType.RentalType AS RentalType_RentalType, AS Software_id, Software.CustomerId AS Software_CustomerId, Software.SoftwareTypeId AS Software_SoftwareTypeId, Software.ApiUrl AS Software_ApiUrl, Software.Code AS Software_Code, Software.Username AS Software_Username, Software.Password AS Software_Password, Software.ClientId AS Software_ClientId, Software.ApiKey AS Software_ApiKey, Software.Title AS Software_Title, Software.AutoSyncFlag AS Software_AutoSyncFlag, Software.DateCreated AS Software_DateCreated, Software.DateUpdated AS Software_DateUpdated, AS Staff_id, Staff.CustomerId AS Staff_CustomerId, Staff.StaffTypeId AS Staff_StaffTypeId, Staff.ContactId AS Staff_ContactId, Staff.Password AS Staff_Password, Staff.EnabledFlag AS Staff_EnabledFlag, Staff.AccountAdminFlag AS Staff_AccountAdminFlag, Staff.DateCreated AS Staff_DateCreated, Staff.DateUpdated AS Staff_DateUpdated, Staff.DateDisplayed AS Staff_DateDisplayed, AS Contact_id, Contact.Company AS Contact_Company, Contact.FirstName AS Contact_FirstName, Contact.LastName AS Contact_LastName, Contact.Title AS Contact_Title, Contact.Email AS Contact_Email, Contact.DateBirth AS Contact_DateBirth, Contact.DateAnniversary AS Contact_DateAnniversary, Contact.DateCreated AS Contact_DateCreated, Contact.DateUpdated AS Contact_DateUpdated, (SELECT CAST(AVG(CAST(Rating As Decimal(4, 1))) As Decimal(4,1)) FROM Review WHERE RentalId = AND EnabledFlag = 1) As Rental_Rating, (SELECT COUNT(*) FROM RentalMedia INNER JOIN Media ON RentalMedia.MediaId = WHERE RentalMedia.RentalId = AND Media.MediaTypeId IN (1)) AS Rental_ImageCount, (SELECT COUNT(*) FROM RentalMedia INNER JOIN Media ON RentalMedia.MediaId = WHERE RentalMedia.RentalId = AND Media.MediaTypeId IN (10, 11)) AS Rental_VideoCount, (SELECT COUNT(*) FROM Review WHERE Review.RentalId = AS Rental_ReviewCount, (SELECT COUNT(*) FROM SearchView WHERE SearchView.RentalId = AND DATEADD(MONTH, 1, SearchView.DateCreated) > GETDATE()) AS Rental_SearchViewCount, MinRateNight.MinNight As Rental_MinNightRate, AvgRateNight.AvgNight As Rental_AvgNightRate, MinRateWeek.MinWeek As Rental_MinWeekRate, MinRateMonth.MinMonth As Rental_MinMonthRate, (CASE WHEN MinRateNight.MinNight IS NULL AND MinRateWeek.MinWeek IS NULL THEN 9999999 WHEN MinRateNight.MinNight IS NOT NULL THEN MinRateNight.MinNight ELSE MinRateWeek.MinWeek / 7 END) AS Rental_MinRateSorted, (SELECT TOP 1 TurnDay FROM TurnDay WHERE TurnDay.RentalId = As Rental_TurnDay, (SELECT TOP 1 MinNights FROM Restriction WHERE Restriction.RentalId = As Rental_MinNights, (SELECT TOP 1 Message FROM SoftwareLog WHERE SoftwareLog.SoftwareId = Rental.SoftwareId AND SoftwareLog.Code = Rental.Code) AS Rental_SoftwareLogMessage, Special.Code As Rental_PromoCode, Special.DiscountPer As Rental_DiscountPer, (SELECT TOP 1 LOWER(CAST(CAST( AS VARCHAR) + ISNULL('-' + CAST(Media.MediaUrl AS VARCHAR(200)), '') + '.' + MediaType.MediaType AS VARCHAR(200))) FROM Media INNER JOIN MediaType ON Media.MediaTypeId = INNER JOIN RentalMedia ON = RentalMedia.MediaId WHERE Media.MediaTypeId BETWEEN 1 AND 9 AND RentalMedia.RentalId = AND Media.Position = 1 ORDER BY Media.Position) AS Rental_ImageUrl_1 FROM Rental INNER JOIN Address On Rental.AddressId = INNER JOIN Content On Rental.ContentId = INNER JOIN Customer On Rental.CustomerId = INNER JOIN RentalType On Rental.RentalTypeId = LEFT OUTER JOIN AddressType On Address.AddressTypeId = LEFT OUTER JOIN Software On Rental.SoftwareId = LEFT OUTER JOIN Staff On Rental.StaffId = LEFT OUTER JOIN Contact On Staff.ContactId = LEFT OUTER JOIN (SELECT MIN(Rate.MinRate) As MinNight, Rate.RentalId FROM Rate WHERE PastFlag = 0 AND RateTypeId = 1 GROUP BY Rate.RentalId) As MinRateNight On MinRateNight.RentalId = LEFT OUTER JOIN (SELECT AVG(Rate.MinRate) As AvgNight, Rate.RentalId FROM Rate WHERE PastFlag = 0 AND RateTypeId = 1 GROUP BY Rate.RentalId) As AvgRateNight On AvgRateNight.RentalId = LEFT OUTER JOIN (SELECT MIN(Rate.MinRate) As MinWeek, Rate.RentalId FROM Rate WHERE PastFlag = 0 AND RateTypeId = 2 GROUP BY Rate.RentalId) As MinRateWeek On MinRateWeek.RentalId = LEFT OUTER JOIN (SELECT MIN(Rate.MinRate) As MinMonth, Rate.RentalId FROM Rate WHERE PastFlag = 0 AND RateTypeId = 3 GROUP BY Rate.RentalId) As MinRateMonth On MinRateMonth.RentalId = LEFT OUTER JOIN (SELECT TOP 1 Special.Code, Special.DiscountPer, RentalGroup.RentalId FROM Special INNER JOIN WebPage On Special.WebPageId = INNER JOIN RentalGroup On = RentalGroup.WebPageId WHERE WebPage.WebPageTypeId = 10 AND WebPage.HiddenFlag = 0 AND getDate() BETWEEN WebPage.DateStarts AND WebPage.DateEnds ORDER BY WebPage.DateStarts DESC) As Special ON Special.RentalId = WHERE IS NOT NULL AND Rental.CustomerId IN (1000) AND Rental.RentalTypeId IN (1) AND Rental.EnabledFlag = 1 AND Address.City IN (@City0,@City1,@City2) And (EXISTS(SELECT * FROM RentalFeature WHERE RentalId = AND FeatureId = 2061 AND FeatureValue IN ('Condo','Penthouse'))) And (EXISTS(SELECT * FROM RentalFeature WHERE RentalId = AND FeatureId = 2062 AND FeatureValue IN ('Beach Front'))) And (EXISTS(SELECT * FROM RentalFeature WHERE RentalId = AND FeatureId = 2061 AND FeatureValue IN ('Condo','Penthouse')) Or EXISTS(SELECT * FROM RentalFeature WHERE RentalId = AND FeatureId = 2062 AND FeatureValue IN ('Beach Front'))) ORDER BY Rental_MinRateSorted,Rental_MinNightRate,Rental_MinWeekRate,Rental_Priority DESC,Rental_DateDisplayed