4つのテーブルから値を読み取っています
select '1' as htl_EventId,
'Reading Records' + cast(rank() OVER (ORDER BY ReadingRecord_Id) as varchar) as htl_EventTitle,
dateadd(dd,01,Reading_Date) as htl_StartDate ,dateadd(dd,01,Reading_Date) as htl_EndDate,'White' as htl_Colour,'ForestGreen' as htl_TextColour,'This is your Reading no ' + cast(rank() OVER (ORDER BY ReadingRecord_Id) as varchar) as htl_EventDescription,
'http://google.co.in' as htl_UrlValue
from Reading_Records where User_Id=@UserID and Reading_Date between
convert(date, @StartDate, 103) and convert(date, @EndDate, 103)
--order by Start_Date ASC
--('#' + cast((select ABS(CHECKSUM(NEWID())) % 900000000 + 100000000) as nvarchar)) as htl_Colour,
union
select '2' as htl_EventId,
'Incident Details' + cast(rank() OVER (ORDER BY Incident_Id ) as varchar) as htl_EventTitle,
dateadd(dd,01,From_Date) as htl_StartDate ,dateadd(dd,01,coalesce(To_Date,from_Date)) as htl_EndDate,'maroon' as htl_Colour,'Black' as htl_TextColour, 'This is your Incident no ' + cast(rank() OVER (ORDER BY Incident_Id ) as varchar) as htl_EventDescription,
'http://gmail.co.in' as htl_UrlValue
from User_Incidents where User_Id=@UserID and From_Date >=
convert(date, @StartDate, 103) and To_Date <= convert(date, @EndDate, 103) and status='True'
--order by From_Date ASC
union
select '3' as htl_EventId,
'HealthConditions' + cast(rank() OVER (ORDER BY Condition_Id ) as varchar) as htl_EventTitle,
dateadd(dd,01,Start_MonthYear) as htl_StartDate ,dateadd(dd,01,Start_MonthYear) as htl_EndDate,'maroon' as htl_Colour,'Red' as htl_TextColour,'This is your HealthCondition no ' + cast(rank() OVER (ORDER BY Condition_Id ) as varchar) as htl_EventDescription,
'http://facebook.com' as htl_UrlValue
from User_Health_Condition where User_Id=@UserID and Start_MonthYear between
convert(date, @StartDate, 103) and convert(date, @EndDate, 103) and status='True'
order by 1 ASC
何か提案をお願いしますか?前もって感謝します 。上記のクエリをもう1つ追加する必要があります
select '1' as htl_EventId,
dateadd(dd,01,Reading_Date) as htl_StartDate ,dateadd(dd,01,Reading_Date) as htl_EndDate,DR.Reading_Name as htl_ReadingName
from Reading_Records RR LEFT OUTER JOIN DBO.[Defined_Readings] DR ON RR.Reading_Id=DR.Reading_Id where User_Id=@UserID