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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:44:18+00:00 2026-05-23T03:44:18+00:00

I currently have an asp.net page, that takes in the data from this view

  • 0

I currently have an asp.net page, that takes in the data from this view and based on the percentage it will change the text of an amount field. Meaning that if a user reaches a certain percentage they get a certain incentive amount.

However, I am currently doing this in my program however, for reporting purposes i want to be able to do this straight directly in sql, and not in my asp.net page.

what i am trying to do is almost
something like if percentage column =
65 to 70 percent then amount column =
50 if percentage column = 70 to 75
percent then amount column = 75

straight in my dataview and not in my
asp.net page

If Decimal.Parse(percent.Text) >= 0.65 And percent.Text < 0.7 Then
                Amount.Text = 50
            ElseIf Decimal.Parse(percent.Text) >= 0.7 And percent.Text < 0.75 Then
                Amount.Text = 75
            ElseIf Decimal.Parse(percent.Text) >= 0.75 And percent.Text < 0.8 Then
                Amount.Text = 200
            ElseIf Decimal.Parse(percent.Text) >= 0.8 And percent.Text < 0.85 Then
                Amount.Text = 500
            ElseIf Decimal.Parse(percent.Text) >= 0.85 And percent.Text < 0.9 Then
                Amount.Text = 625
            ElseIf Decimal.Parse(percent.Text) >= 0.9 And percent.Text < 0.95 Then
                Amount.Text = 750
            ElseIf Decimal.Parse(percent.Text) >= 0.95 And percent.Text < 1.0 Then
                Amount.Text = 1000 

Here is my view query, i almost want to add an if statement but im not sure if it is the best way of doing this.

SELECT     TOP (100) PERCENT SUM(yes) AS Countreported, SUM(no) AS Countnotreported, SUM(yes) + SUM(no) AS count, BMM, BYYYY, userid, SUM(pax) 
                          AS party, CAST(SUM(yes) AS decimal(4, 1)) / (SUM(yes) + SUM(no)) AS percentage
    FROM         (SELECT     SUM(CASE WHEN [insreported] IS NULL THEN 0 WHEN [insreported] = 'YES' THEN 1 ELSE 0 END) AS yes, 
                                                  SUM(CASE WHEN [insreported] IS NULL THEN 1 WHEN [insreported] = 'YES' THEN 0 ELSE 1 END) AS no, CASE WHEN USERID = 'chrisn' OR
                                                  USERID = 'CHRISN' THEN 'chrism' ELSE USERID END AS userid, dbo.agent_insurance_incentive_data.BMM, 
                                                  dbo.agent_insurance_incentive_data.BYYYY, SUM(dbo.agent_insurance_incentive_data.PARTY) AS pax, 
                                                  dbo.incentive_agents.department
                           FROM          dbo.agent_insurance_incentive_data LEFT OUTER JOIN
                                                  dbo.incentive_agents ON dbo.agent_insurance_incentive_data.USERID = dbo.incentive_agents.agent
                           WHERE      (dbo.agent_insurance_incentive_data.DYYYY >= '2009') AND (dbo.agent_insurance_incentive_data.BYYYY > 2008)
                           GROUP BY dbo.agent_insurance_incentive_data.USERID, dbo.agent_insurance_incentive_data.BMM, dbo.agent_insurance_incentive_data.BYYYY, 
                                                  dbo.agent_insurance_incentive_data.DMM, dbo.agent_insurance_incentive_data.DYYYY, dbo.incentive_agents.department) 
                          AS derived
    WHERE     (userid IN
                              (SELECT     agent
                                FROM          dbo.incentive_agents AS incentive_agents_1)) OR
                          (userid = 'chrisn')
    GROUP BY BMM, BYYYY, userid
    ORDER BY userid, BYYYY, BMM
  • 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-23T03:44:18+00:00Added an answer on May 23, 2026 at 3:44 am

    Conceptually this should be fairly simple. Just adopt the following formula to your query.

    Declare @Tmp Table(
        Percentage float 
    )
    
    Insert Into @Tmp Values (.65)
    Insert Into @Tmp Values (.7)
    Insert Into @Tmp Values (.75)
    Insert Into @Tmp Values (.8)
    Insert Into @Tmp Values (.85)
    Insert Into @Tmp Values (.9)
    Insert Into @Tmp Values (.95)
    
    SELECT 
        CASE
            WHEN Percentage >= .65 AND Percentage < .7 THEN 50
            WHEN Percentage >= .7 AND Percentage < .75 THEN 75
            WHEN Percentage >= .75 AND Percentage < .8 THEN 200
            WHEN Percentage >= .8 AND Percentage < .85 THEN 500
            WHEN Percentage >= .85 AND Percentage < .9 THEN 625
            WHEN Percentage >= .9 AND Percentage < .95 THEN 750
            WHEN Percentage >= .95 AND Percentage < 1 THEN 1000
        END AS Amount,
        Percentage
    FROM 
        @Tmp
    

    EDIT:

    Since I can’t (don’t have the time) to re-create your tables & data.

    Shouldn’t you be able to do something like:

    SELECT 
        CASE
            WHEN Percentage >= .65 AND Percentage < .7 THEN 50
            WHEN Percentage >= .7 AND Percentage < .75 THEN 75
            WHEN Percentage >= .75 AND Percentage < .8 THEN 200
            WHEN Percentage >= .8 AND Percentage < .85 THEN 500
            WHEN Percentage >= .85 AND Percentage < .9 THEN 625
            WHEN Percentage >= .9 AND Percentage < .95 THEN 750
            WHEN Percentage >= .95 AND Percentage < 1 THEN 1000
        END AS Amount,
        *   
    FROM 
    (
        --Insert your query here
    )Tmp2
    
    --OR IF SQL doesn't like the GroupBy/OrderBy statements in the Sub Select 
    
    Declare @Tmp3 Table(
        Countreported float,
        Countnotreported float,
        [count] float,
        BMM float,
        BYYYY float,
        userid int, 
        party int, 
        percentage decimal
    )
    
    INSERT INTO @Tmp3
        --Insert your query here
    
    SELECT 
        CASE
            WHEN Percentage >= .65 AND Percentage < .7 THEN 50
            WHEN Percentage >= .7 AND Percentage < .75 THEN 75
            WHEN Percentage >= .75 AND Percentage < .8 THEN 200
            WHEN Percentage >= .8 AND Percentage < .85 THEN 500
            WHEN Percentage >= .85 AND Percentage < .9 THEN 625
            WHEN Percentage >= .9 AND Percentage < .95 THEN 750
            WHEN Percentage >= .95 AND Percentage < 1 THEN 1000
        END AS Amount,
        *   
    FROM 
        @Tmp3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button on my ASP.NET page, which fetches some data from my
I have a project that needs to be done using ASP.NET. Currently, I'm using
I've got an ASP.NET page that takes a long time to download and returns
I am currently working on an ASP.net c# project. I have an aspx page
I have a WCF webservice that acts as a data provider for my ASP.NET
I have a this asp.net page which upon first time load: 1: Make a
I have a site that I am currently working on in ASP.NET 2.0 using
I currently have an ASP.NET GridView that displays a few columns to the user
I currently have an Instance of the ASP.net ajax control toolkit combo box residing
I have an ASP.NET Webform which currently calls a Java WebService. The ASP.NET Webform

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.