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 8001225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:02:21+00:00 2026-06-04T16:02:21+00:00

I am attempting to translate a SQL CASE statement but am running into some

  • 0

I am attempting to translate a SQL CASE statement but am running into some problems and was hoping I could get a hand. Here is the statement:

,SUM(CASE WHEN [Gads].[GadsEventTypeCode] IN ('D1', 'D2', 'D3', 'DP', 'PD', 'DM', 'D4')
    THEN [Allocation].[AllocatedEnergyMwh] ELSE 0 END / 
    CAST([Unit].[NetDependableCapacity] AS FLOAT)) AS Hrs_Derate

This is what I come up with but get “lost in translation”:

If [Gads].[GadsEventTypeCode] equals 'D1', 'D2', 'D3', 'DP', 'PD', 'DM', 'D4'
then Hrs_Derate equals the sum of:
[Allocation].[AllocatedEnergyMwh] / [Unit].[NetDependableCapacity]
else Hrs_Derate equals zero.

  • 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-06-04T16:02:25+00:00Added an answer on June 4, 2026 at 4:02 pm

    You have three elements that you need to translate:

    1. CASE statement – this can be handled with a ternary expression, e.g., (cond) ? trueval : falseval
    2. IN clause – there is the LINQ .Contains operator which can check if an element is contained inside an array.
    3. Casting – the cast operator I believe is handled via the same methods in System.Convert.

    Armed with these three translation rules, you would need something like this (untested):

    var types = new [] { "D1", "D2", "D3", "DP", "PD", "DM", "D4" };
    
    Hrs_Derate =
        ((types.Contains(gads.GadsEventTypeCode) ? allocation.AllocatedEnergyMwh : 0)
        / (Convert.ToFloat(unit.NetDependableCapacity))).Sum()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to translate the following C# code into IronPython but I don't know
I'm attempting to translate some C++ code into Java. I'm looking for the best
I'm attempting to translate an existing Access report into a client-side SSRS 2008 report,
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
Attempting to run a MIB based SNMP script and I running into an issue.
I'm attempting to embed the very convenient Google Translate translate element into a webpage,
I'm attempting to convert some effects created in Photoshop into code for use with
I have been attempting to split a div into two columns using CSS, but
I am attempting to translate two separate algorithms into Java code in order to
I'm attempting to get my first NHibernate project up and running in Mono/openSUSE 11.4.

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.