SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/03/31'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/03/31'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/01'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/01'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/02'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/02'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/03'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/03'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/04'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/04'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/07'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/07'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/08'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/08'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/09'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/09'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/10'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/10'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/11'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/11'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/14'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/14'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/15'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/15'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/16'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/16'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/17'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/17'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/18'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/18'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/21'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/21'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/22'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/22'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/23'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/23'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/24'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/24'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title
SELECT calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone, max(p.portfolioID) as portfolioID,
sec.sector,CASE WHEN (sec.sectorurl IS NULL OR sec.sectorurl = '')
THEN 'sector'
ELSE sec.sectorurl
END as SectorURL
FROM (
select seasonReport,calendarID, source, externalID, title, symbol, itemdate, isDisplayed, 1 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/25'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol != '')
UNION
select seasonReport,calendarID, source, externalID, title, type AS symbol, itemdate, isDisplayed, 0 as display, timezone
from calendar c left join countrycode cc on c.type = cc.code
where convert(varchar(10),itemDate,111) = '2025/04/25'
AND isDisplayed = 1
AND seasonReport = 1
AND (symbol = '')
) AS calendar
left join (select p.* from portfolio p inner join customerportfolio cp on p.CustomerPortfolioID = cp.CustomerPortfolioID where cp.customerid = '' and cp.archived is NULL)
p on calendar.symbol = p.symbol
LEFT JOIN (SELECT sr.symbol, s.sector,s.sectorID,dbo.RemoveNonAlphaCharacters(s.sector) as sectorurl FROM sector s
INNER JOIN SectorRelationship sr on s.sectorID = sr.sectorID
WHERE isPriority = 1) AS sec on calendar.symbol = sec.symbol
GROUP BY calendar.calendarID,calendar.source,calendar.externalID,
calendar.title,calendar.symbol,calendar.itemdate,calendar.isDisplayed,
calendar.display,calendar.timezone,sec.Sector,sec.sectorurl
ORDER BY calendar.display, calendar.timezone desc, calendar.symbol, calendar.title