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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:38:11+00:00 2026-06-03T01:38:11+00:00

I am using SQL Server 2000. I am trying to calculate Net Promoter Score

  • 0

I am using SQL Server 2000. I am trying to calculate Net Promoter Score or NPS based on the below formula

Formula: (Promoters - Detractors) / Total Questions

  • Scores 9 – 10 are considered promoters.
  • Scores 0 – 6 are considered detractors.
  • Scores 7 – 8 are considered neutral.

I have the following data:

Time           Q1      Q2      Q3
-----------  ------  ------  ------
2012-03-14      7       7       5
2012-03-15      3       2       5
2012-03-15      7      NA       2
2012-03-15      9      10     NULL
2012-03-15      8       4       4
2012-03-15     NA       6       4
2012-03-16      1       7       4
2012-03-16     NULL     0       5
2012-03-17      9       9       2
2012-03-19      0       0       1
2012-03-19      8       5       4
2012-03-19      1       0       3

The person who originally wrote the database stored NULL values as blanks or NA enter code herein a NVARCHAR format (only god knows why..) so the query I am playing with now uses a ISNUMERIC and im trying not to count blank or NA values.

My query, which doesnt work properly looks like:

 SELECT CAST(SUM(CASE WHEN ISNUMERIC([Q1]) != 1 THEN 0
             WHEN CAST([Q1] AS int) >= 9 THEN 1
             WHEN CAST([Q1] AS int) <= 6 THEN -1
             ELSE 0 END)
    + SUM(CASE WHEN ISNUMERIC([Q2]) != 1 THEN 0
             WHEN CAST([Q2] AS int) >= 9 THEN 1
             WHEN CAST([Q2] AS int) <= 6 THEN -1
             ELSE 0 END)
    + SUM(CASE WHEN ISNUMERIC([Q3]) != 1 THEN 0
             WHEN CAST([Q3] AS int) >= 9 THEN 1
             WHEN CAST([Q3] AS int) <= 6 THEN -1
             ELSE 0 END)
   AS FLOAT)
    / (SUM(CASE WHEN ISNUMERIC([Q1]) != 1 THEN 0
               ELSE 1 END)
    + SUM(CASE WHEN ISNUMERIC([Q2]) != 1 THEN 0
               ELSE 1 END)
    + SUM(CASE WHEN ISNUMERIC([Q3]) != 1 THEN 0
               ELSE 1 END)
   ) as [NPS]
FROM [nps]

Can someone point me in the right direction?
Thanks!

  • 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-03T01:38:12+00:00Added an answer on June 3, 2026 at 1:38 am

    As others pointed out, changing the data type of the column from NVARCHAR to INT would be ideal.

    Here is the query that might help you get the result that you need.

    Click here to view the demo in SQL Fiddle using SQL Server 2012

    Script:

    SELECT  
            (
                SUM (CASE WHEN q >= 9 THEN 1.  END) -
                SUM (CASE WHEN q <= 6 THEN 1.  END)
            ) /
            SUM (1.) AS nps
    FROM
    (
            SELECT  (CASE   
                        WHEN ISNUMERIC(q1) <> 1 THEN 0. 
                        ELSE CAST(q1 AS FLOAT) 
                    END) AS q   
            FROM [nps] 
        UNION ALL 
            SELECT  (CASE 
                        WHEN ISNUMERIC(q2) <> 1 THEN 0. 
                        ELSE CAST(q2 AS FLOAT) 
                    END) AS q   
            FROM [nps] 
        UNION ALL 
            SELECT  (CASE 
                        WHEN ISNUMERIC(q3) <> 1 THEN 0. 
                        ELSE CAST(q3 AS FLOAT) 
                    END) AS q   
            FROM [nps] 
    ) nps;
    

    Output:

    np
    ---------
    -0.611111
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SQL Server 2000 and ASP.Net with c# for making a search
Using SQL Server 2000 I am trying to use this command in Query Analyzer
I'm trying to migrate from sql server 2000 to mysql by using DTS. That's
I'm using SQL Server 2000 and i'm trying to run an update query to
Using Vb.net/SQL Server 2000 updating a row via a gridview/sqldatasource Stored proc: @ISTag varchar(10),
Using sql server 2000, I would like to take my production data and put
Using SQL Server 2000 Table PersonID Date 001 11-02-2009 002 11-02-2009 003 11-02-2009 001
Using SQL Server 2000 My Query. SELECT (Format(IIf(CLng(OutTime) > 180000, CDate('18:00:00'), CDate(Format(OutTime, '00:00:00'))) -
I'm using SQL Server 2000 to print out some values from a table using
I am using SQL Server 2000 and I have two databases that both replicate

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.