Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 20764

how to get only postcode in my query

$
0
0

i have following query i want only highlighted post code how to get this please help me i want result like this Via1: PostCode, Via2 :PostCode ,Via3: PostCode

CREATE TABLE booking ( ID int IDENTITY(1,1) PRIMARY KEY, address varchar(255) ) insert into booking values('NORTHWICK AVENUE HARROW HA3 0AB') insert into booking values('CHANCERY LANE LONDON WC2A 1AB') CREATE TABLE Booking_ViaLocations ( ID int IDENTITY(1,1) PRIMARY KEY, BookingId int, ViaLocations varchar(255) ) insert into Booking_ViaLocations values (1,'NORTHWICK AVENUE HARROW HA3 0AB') insert into Booking_ViaLocations values (1,'CHANCERY LANE LONDON WC2A 1AB') insert into Booking_ViaLocations values (1,'NEW OXFORD STREET LONDON WC1A 1BA') SELECT STUFF( ( SELECT ' , Via ' + CAST(ROW_NUMBER() OVER (ORDER BY t1.BookingId asc) AS VARCHAR(4))+ ' : ' + right(t2.ViaLocValue, charindex(' ', reverse(t2.ViaLocValue), charindex(' ', reverse(t2.ViaLocValue)) + 1) - 1) FROM Booking_ViaLocations t2 WHERE t2.BookingId = t1.BookingId FOR XML PATH ('') ) ,1,2,'') AS Names FROM Booking_ViaLocations t1 inner join Booking b on t1.BookingId = b.Id GROUP BY t1.BookingId



Viewing all articles
Browse latest Browse all 20764


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>