Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT  prh.header_id  , prh.staff_id  , prh.name  , prh.description  , prh.create_date  , prh.timezone_id  , m.market_id
    , m.market_name  , agy.agency_id , agy.agency_name  , adv.advertiser_id  , adv.advertiser_name  , prh.product
    , prh.survey_id  , o.office_id  , o.office_name  , ae_staff_id  , st.first_name AS ae_first_name  ,
 st.last_name AS ae_last_name , prh.flight_start_date  , prh.flight_end_date  , prh.flight_month  , prh.demo_id 
 , d.demo_name  , prh.points_goal  , prh.syscode_summary , prh.network_summary  , prh.daypart_summary , 
prh.weekly_summary, prh.bmonth_summary  , prh.client_code  , prh.product_code  , prh.estimate_code  , prh.geography_id  , 
g.description as geography_name  , prh.survey_source_id , ss.source as survey_source_name, prh.show_hh
    , isnull(prh.show_survey, 0) as show_survey  , isnull(prh.display_type, 0) as display_type  , 
isnull(prh.Show_Ratings_Imps, 3) as Show_Ratings_Imps , isnull(prh.Zone_Consolidate, 0) as Zone_Consolidate , 
isnull(prh.Order_Num_Display, prh.survey_id) as Order_Num_Display , isnull(prh.Total_GRPs, 0) as Total_GRPs
   , (SELECT EST.iPlus FROM NCCCableBuy.dbo.Survey SUR JOIN NCCCableBuy.dbo.Estimate EST ON 
SUR.Estimate_ID = EST.Estimate_ID
    WHERE (SUR.Survey_ID = prh.Survey_ID)) AS iPlus
        FROM post_saved_report_header prh
         LEFT JOIN survey_source ss on prh.survey_source_id = ss.survey_type_id
         LEFT JOIN geo_type g on prh.geography_id = g.geo_id
         LEFT JOIN market m ON prh.market_id = m.market_id
         LEFT JOIN ac_agency agy ON prh.agency_id = agy.agency_id
         LEFT JOIN ac_advertiser adv ON prh.advertiser_id = adv.advertiser_id
         LEFT JOIN staff st ON prh.ae_staff_id = st.staff_id
         LEFT JOIN office o ON prh.office_id = o.office_id
         LEFT JOIN demo d ON prh.demo_id = d.demo_id
         WHERE prh.header_id = 246
Posted
Updated 11-Oct-15 19:57pm
v2

A a quick glance, try to remove the query to get data for iPlus column. Try and add a join to get that data. Other than that, you might need to look into amount of data these tables have, your database design and also the hardware.

Take a look at the execution plan to identify which operation takes more time.
 
Share this answer
 
v2
Hi,

Check this...


How Do I Speed Up My Select * Query Of "530,000" Rows[^]


Hope this will help you.

Cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900