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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:13:09+00:00 2026-05-28T05:13:09+00:00

I have an Excel sheet and have this formula below. I would like to

  • 0

I have an Excel sheet and have this formula below. I would like to calculate the same formula with sql. In excel formula there is a nested if condition. Is it possible with sql ? I have tried with “Case .. When .. Then .. Else ..” but I could not manage! In my excel sheet this calculation result is “OK”

Thank you,

Declare @ProjectName nvarchar(max)
Declare @NewTotalElapsedTimeEnd nvarchar(max)
Declare @TotalElapsedTime nvarchar(max)
Declare @SlaTime nvarchar(max)
Declare @Result nvarchar(max)

set @ProjectName = ''
set @NewTotalElapsedTimeEnd = 0
set @TotalElapsedTime = 69563
set @SlaTime = 86400

Excel Formula

=IF(ProjectName<>"","PROJECTED",IF(NewTotalElapsedTimeEnd=0,IF(TotalElapsedTime-SlaTime<0,"OK","NOK"),IF(NewTotalElapsedTimeEnd-SlaTime<0;"OK";"NOK")))
  • 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-28T05:13:10+00:00Added an answer on May 28, 2026 at 5:13 am

    this should help you (done on MS SQL Server, maybe your database system needs small changes to syntax). Case-when is working fine, but you need to have your timespan values as a number for being able so substract.

    Cheers.

    Declare @ProjectName nvarchar(max)
    Declare @NewTotalElapsedTimeEnd int
    Declare @TotalElapsedTime int
    Declare @SlaTime int
    Declare @Result nvarchar(max)
    
    set @ProjectName = ''
    set @NewTotalElapsedTimeEnd = 0
    set @TotalElapsedTime = 69563
    set @SlaTime = 86400
    
    SET @Result =
        CASE WHEN @ProjectName <> ''
        THEN 'PROJECTED'
        ELSE
            CASE WHEN @NewTotalElapsedTimeEnd = 0
            THEN    
                CASE WHEN @TotalElapsedTime < 0
                THEN 'OK'
                ELSE 'NOK'
                END     
            ELSE
                CASE WHEN (@NewTotalElapsedTimeEnd - @SlaTime) < 0
                THEN 'OK'
                ELSE 'NOK'
                END
            END
        END
    
    SELECT @Result
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel sheet and have this formula below. I would like to
For every week I have excel sheet converted to SQL database this excel sheet
I have this sheet on Excel : Team Total Points Position AJPPR 371,1878896 APP64
I have the this code that will create excel file and work sheet then
I have an excel sheet and was trying to figure out if there was
This is starting to really annoy me! I have an Excel sheet with a
I have this forumula in a Excel sheet : =IF(B$3=0,B$14*B$2*B$6,(1-((1+B$3))^B$6)/LN(1/(1+B$3))*B12*B$2) where cells: B2 =
I have an excel sheet (month payslip) in which there is a payslip with
In excel 2007, I have a formula in a cell like the following: =COUNTIFS('2008-10-31'!$C:$C;>=&'$A7)
I have an excel sheet, where cells A1-C20= =INT(RAND()*10) . This is my data

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.