I have the following two T-SQL statements that I really need to combine.
Any support really appreciated.
AircraftID. Select FlightID, AircraftManufacturers.Name, AircraftModels.ModelName, Aircraft.ModelSuffix, Aircraft.ImageFileName, Aircraft.Year, Aircraft.SerialNo, Locations.DescriptionForSite, as aircraft .description , as Aircraft.Description2, Aircraft.InfoWebAddress, Aircraft.ImageDescription, Advertisers.Id AdvertisersID, Advertisers.Name AdvertisersName, Aircraft.AircraftDataId, Aircraft.ForSale, Aircraft.ForLease, Aircraft.TTAF, Aircraft.ReSend, Aircraft.ReSendReason as, Aircraft.Registration, Aircraft.AdType, Aircraft.HasAlternateImage, Aircraft.AlternateImageDescription, Aircraft.Price, AircraftModels.AircraftType, Advertisers.CurrentEMagLink, Aircraft.CurrentEMagLink, Aircraft.Email, Aircraft.IsSold, Aircraft.SoldDate, Aircraft.DateAdded Aircraft Extended Details, Aircraft. Last updated date, Ayrkra aft.ImageCount, Aircraft.ContactTelephone, AircraftModels.id, Advertisers.IsPremiumAdvertiser, Aircraft.Location, Advertisers.ContactTelephone AdvertisersTelephone, Aircraft.LastUpdateDate, Aircraft.EndDate, Aircraft.VideoLink the (((aircraft interiors the advertiser Aircraft.AdvertiserId = Advertisers.Id) iNNER aviation jet module. aircraft Modelaiaidi = Ayrkraftmodlskaidi) on the inner aircraft Ayrkraftrs aircraft Models. manufacturer manufacturer = aircraft manufacturers. IID) Ayrkraf Add location to T Location ID = Location IAD IT $ simple_interlist_to_tibal (@ id) I on aircondition.od = i.number ou (Aircraft.IsActive = 1 and Advertisers.IsActive = 1 and (Aircraft.EndDate> Date = Date or Aircraft.EndDate Is Null) and Locations .DescriptionForSite like @Location) or (Advertisers.IsActive = 1 and Aircraft.IsSold = 1 and Aircraft.SoldDate & gt; = @ date 2 and Locations.DescriptionForSite like @Location) by Advertisers.IsPremiumAdvertiser ASC, Aircraft.DateAdded DESC, Aircraft .ListPosition order DESC, Aircraft.LastUpdateDate, AircraftManufacturers.Name, AircraftModels.ModelName, Aircraft.ModelSuffix, Aircraft.Id DESC select TOP (1) dbo.Addresses.Email, dbo.Addresses.Contact, dbo.Addresses within dbo.AdvertiserAddressLink .Telephone1 Join dbo.Addresses on dbo.AdvertiserAddres SLink.AddressId = dbo.Addresses.Id (dbo.AdvertiserAddressLink.AdvertiserId = 'AdvertisersID') & lt; - See above and dbo.Addresses.AddressType = 1 or dbo.Addresses.AddressType = 0) by order dbo.Addresses.AddressType DESC, dbo.Addresses.Sequence Thanks
It seems that you already have a correlated parameter based on the second query in TOP 1 You apply for this. A simple example.
from SELECT.t.name ca.name, sys.tablesc CROSAP application (SELECT TOP 1 * Sys.column from c to WHERE c.object_id = name t.object_id name)
Comments
Post a Comment