One field reference in a view result for two different tables
Hello,
I have written a view which shows all the results depending on the description type then shows the reference number, it is displaying correctly but how can I just show the result in the same column ie as CemCRem ref (without referring to burial or cremation)
--Cremation or Burial details
case k.Description when 'White' then j.BOOKINGNO end AS [Reference White],
case k.Description when 'Black' then f.BOOKINGNO end AS [Reference Black],
Note the booking reference comes from different tables. but in the view I want to show it as one field in the view as 'Reference' not Reference White Reference Black
Microsoft SQL ServerMicrosoft SQL Server 2008SQL
Last Comment
Amanda Walshaw
8/22/2022 - Mon
keyu
take one temp table store all values inside itand fire /execute select query.
Can you post a sample of data, how you are getting the result now and how you want all in data format? That will help us to better get the requirement.
create table #temp( refnumber varchar(4000),refnumber1 varchar(4000))
insert into #temp select id,case k.Description when 'White' then j.BOOKINGNO end AS [Reference White] from table_name
insert into #temp select id,case k.Description when 'Black' then f.BOOKINGNO end AS [Reference Black] from table_name
select refnumber ,refnumber1 from #temp