Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7189419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:17:53+00:00 2026-05-28T19:17:53+00:00

I have a reasonably long SQL query that I need to run in a

  • 0

I have a reasonably long SQL query that I need to run in a .Net application. I can make it a stored procedure but I’d like to avoid it if possible (given that I may have a high number of queries in this app).

With this in mind, could something like the following be converted to LINQ or is it too detailed?

-- Compare current period to historical data
select  Name ,
        avg(TimeProcessing + TimeRendering + TimeDataRetrieval) / 1000  as 'Current Month' ,
        isnull(count(TimeProcessing), 0)                                as 'Sample' ,
        min(l2.[Avg_Exec_Time_Previous_Month])                          as 'Previous Month' ,
        isnull(min(l2.[Executions_Last_Month]), 0)                      as 'Sample' ,
        min(l3.[Avg_Exec_Time_Two_Months_Ago])                          as 'Two Months ago' ,
        isnull(min(l3.[Executions_Two_Months_Ago]), 0)                  as 'Sample'
from    marlin.report_execution_log l
        inner join marlin.report_catalog c on l.ReportID = c.ItemID
        left outer join ( 
                        select    
                            l2.ReportID ,
                            (
                            avg(l2.TimeProcessing + l2.TimeRendering 
                            + l2.TimeDataRetrieval) / 1000 
                            ) as 'Avg_Exec_Time_Previous_Month' ,
                            count(l2.TimeProcessing) as 'Executions_Last_Month'
                        from    
                            marlin.report_execution_log l2
                        where   
                            TimeEnd between dateadd(MONTH, -2, getdate())
                                    and     dateadd(MONTH, -1, getdate())
                        group by  
                            l2.ReportID
                        ) l2 on l.ReportID = l2.ReportID
        left outer join ( 
                        select    
                            l3.ReportID ,
                            (
                            avg(l3.TimeProcessing + l3.TimeRendering + l3.TimeDataRetrieval) / 1000 
                            ) as 'Avg_Exec_Time_Two_Months_Ago' ,
                            count(l3.TimeProcessing) as 'Executions_Two_Months_Ago'
                        from  
                            marlin.report_execution_log l3
                        where 
                            TimeEnd between dateadd(MONTH, -3, getdate())
                                    and     dateadd(MONTH, -2, getdate())
                        group by  
                            l3.ReportID
                        ) l3 on l.ReportID = l3.ReportID
group by    l.ReportID ,
            Name
order by    2 desc
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:17:54+00:00Added an answer on May 28, 2026 at 7:17 pm

    there are many tools /convertor are available on the internet. you can use this tools

    • why not you try Sql to Linq
    • LinqPad
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you have any formal or informal standards for reasonably achievable SQL query speed?
I have a reasonably long list of websites that I want to download the
I have not been working in SQL too long, but I thought I understood
I have a long running, compute and disk intensive task that needs to run
I have a reasonably advanced (many patches and subpatches) quartz composition that was created
I have inherited a reasonable sized ASP.net solution that has no automated tests. The
I have a class that can perform many types of transformations to a given
I have a web application that relies on very live data - so it
I have a reasonably complex layout problem: I would like to have a main
Environment: Team Foundation Server 2005 Visual Studio 2008 I have a reasonably large project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.