Hello, pretty new to SQL and need help optimizing this statement as it is VERY slow. Basically what I am doing is getting the monthly counts and percentages from a table of over 1.5 million records. There are four categories that I needs counts from based on a value in a text field. I'm sure I am missing some obvious way to completely rewrite this query but right now it alludes me. Any help would be greatly appreciated!select distinct MONTH(o.order_create_dt) + YEAR(o.order_create_dt) * 100 as order_id , DATENAME(month, o.order_create_dt) + ' ' + DATENAME(year, o.order_create_dt) as Month_Name , convert(decimal(6,2),convert(numeric,(select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt) and quote_src_cd = 'IFO_A')) / convert(numeric,(select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt))) * 100.0) as IFO_A_PERCENT , convert(decimal(6,2),convert(numeric,(select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt) and quote_src_cd = 'IFO_B')) / convert(numeric,(select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt))) * 100.0) as IFO_B_PERCENT , convert(decimal(6,2),convert(numeric,(select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt) and quote_src_cd = 'IFO_C')) / convert(numeric,(select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt))) * 100.0) as IFO_C_PERCENT , convert(decimal(6,2),convert(numeric,(select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt) and quote_src_cd = 'IFO_D')) / convert(numeric,(select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt))) * 100.0) as IFO_D_PERCENT , (select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt)) as TOTAL_COUNT , (select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt) and quote_src_cd = 'IFO_A') as IFO_A_COUNT , (select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt) and quote_src_cd = 'IFO_B') as IFO_B_COUNT , (select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt) and quote_src_cd = 'IFO_C') as IFO_C_COUNT , (select COUNT(*) from sp_tmp_ifo_adoption i where MONTH(i.order_create_dt) = MONTH(o.order_create_dt) and year(i.order_create_dt) = year(o.order_create_dt) and quote_src_cd = 'IFO_D') as IFO_D_COUNT from sp_tmp_ifo_adoption o