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

  • Home
  • SEARCH
  • 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 8414837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:16:12+00:00 2026-06-10T01:16:12+00:00

In my select statement, I have two returns that are calculations. It looks like

  • 0

In my select statement, I have two returns that are calculations. It looks like this:

 SELECT
     a.FormRate AS 'F-Rate'
     ,a.LoI AS 'Liability'
     ,CAST((A.FormRate * a.LoI / 100) AS DECIMAL(38,2)) 'F-Premium'
     ,a.EndorsementRate AS 'E-Rate'
     ,CAST((A.EndorsementRate * a.LoI / 100) AS DECIMAL(38,2)) 'E-Premium' 

FROM tblAspecs a

Once I have those five statements in the select, I’d like to be able to total E-Premium + F-Premium into a new column. I could always do it this way:

  ,CAST(((A.EndorsementRate * a.Loi / 100) + (a.FormRate * a.LoI / 100)) AS DECIMAL(38,2)) 'Total Premium'

…but that just just seems to be quite sloppy and bulky. Is there a way to store the individual premiums so that I can just do a simple CAST((F-Premium + E-Premium) AS DECIMAL(38,2)) 'Total Premium'

The bulky way also doesn’t leave F-Premium and E-Premium dynamic so that if I ever change how they’re calculated, I’d have to also change the calculation in the Total Premium column.

Using Microsoft SQL Server Management Studio 2010

  • 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-10T01:16:14+00:00Added an answer on June 10, 2026 at 1:16 am

    Research Common Table Expressions.

    It will look something like this:

    ;WITH [Data]
    (
        [FormRate],
        [Liability],
        [FormPremium],
        [EndorsementRate],
        [EndorsementPremium]
    )
    AS
    (
        SELECT
             a.[FormRate],
             a.[LoI] AS [Liability],
             CAST((a.[FormRate] * a.[LoI] / 100) AS DECIMAL(38,2)),
             a.[EndorsementRate],
             CAST((a.[EndorsementRate] * a.[LoI] / 100) AS DECIMAL(38,2)) 
        FROM 
            tblAspecs a
    )
    SELECT
        [Data].*,
        CAST(([Data].[FormPremium] + [Data].[EndorsementPremium]) AS DECIMAL(38,2)) 'Total Premium'
    FROM
        [Data]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a select statement that returns two columns: office names and total per
I have a SELECT statement like this: SELECT T1.COD, T1.NAME, (SELECT MAX(T2.DATA) FROM dbo.TAB2
I have a site with a SELECT statement like this: SELECT * FROM MyTable
I have two tables that look like this: Products: id category name description active
I have two SELECT statements that return a number each, and I'd like to
I have a select statement that returns a field in a table. records =
We have this statement: (SELECT res_bev.bev_id, property_value.name AS priority FROM res_bev, bev_property, property_value WHERE
I have this ugly SELECT statement : Select 'Urbain' as Véhicule, Count( DISTINCT Plaintes.IDEvenements)
I have two T-SQL scalar functions that both perform calculations over large sums of
I have the following SQL statement: USE ws_results_db_2011_09_11_09_06_24;SELECT table_name FROM INFORMATION_SCHEMA.Tables WHERE table_name like

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.