SELECT CONCAT('F', pup.company_number) AS id, IF( 'EN' = 'EN', pup.company_name, IFNULL(nn.native_name, pup.company_name) ) AS NAME, pup.company_name AS SORT_NAME, pup.company_name AS sort_parent_name, pup.company_number, pup.company_name AS parent_name, 0 AS LEVEL, 'Institution' AS instinsid, pup.ultparentid, pup.ultparentname, pup.htype, pup.investor, pup.Institution_Name AS MFADVISOR, pup.style, pup.mstyle, pup.capgrp, pup.turn, pup.metro, pup.region, pup.subregion, pup.cntry, pup.state, pup.city, IF( 'US' = '@NA' OR pup.iso_country IS NULL, NULL, IF(pup.iso_country = 'US', 'Domestic', 'Foreign') ) AS domfor, opsa.pct_sector AS UKSECT, opca.pct_market AS UKMKT, NULL AS title, IF(pu.cfax = '', NULL, pu.cfax) AS cfax, pup.beta, pup.relstr, pup.aum * 1 AS AUM, pup.eqasset * 1 AS EQASSET, pup.filername, pup.mfcontact, pup.cphone, pup.cadd, pup.cemail, pup.ctitle, pup.actdesc, pup.actscore, pup.sw, pup.pb, pup.divyld, pup.pe, SUM(IF(hh.report_date = '20210630', hh.position, 0)) AS parent_pos, SUM(IF(hh.report_date = '20210331', hh.position, 0)) AS pos0, SUM(IF(hh.report_date = '20210630', hh.position, 0)) AS pos1, NULL AS WATCHLIST, hh.company_number IN( '284159', '9342070', '10992703', '12044185', '12445676', '13371444' ) AS ACTFLAG, SUM( IF(hh.report_date IN ('20200930', '20201231'), 0, 1) ) AS include FROM own_fund_hist_unadjusted_snapshot hh JOIN own_portmas_ultimate pu ON hh.company_number = pu.company_number AND pu.portfolio_type = 'M' JOIN own_portmas_ultimate pup ON pu.inst_id = pup.company_number AND pup.portfolio_type = 'F' INNER JOIN own_secmas s ON hh.cusip = s.cusip LEFT JOIN own_portmas_native nn ON pup.company_number = nn.company_number AND nn.language_code = 'EN' LEFT JOIN own_snapshot h ON hh.cusip = h.cusip AND pup.company_number = h.company_number AND hh.report_date = h.report_date LEFT JOIN own_holdings_hist_prices hhp ON hh.cusip = hhp.CUSIP AND hh.report_date = hhp.Price_Date LEFT JOIN own_portmas_optmv_snapshot optmv ON pup.company_number = optmv.company_number AND hh.report_date = optmv.date AND optmv.type = 'F' LEFT JOIN own_portmas_sector_analytics_fds opsa ON opsa.company_number = hh.company_number AND opsa.code = '3300' AND opsa.iso_country = 'GB' AND opsa.type = 'F' LEFT JOIN own_portmas_country_analytics_uk_fds opca ON opca.company_number = hh.company_number AND opca.type = 'F' LEFT JOIN own_stakes_snapshot sts ON h.cusip = sts.cusip AND h.company_number = sts.company_number AND h.report_date = sts.report_date WHERE hh.cusip = '594918104' AND hh.report_date IN ('20210331', '20210630') AND h.company_number IS NULL GROUP BY pup.company_number