Advertisement

03.25.2008 at 08:26AM PDT, ID: 23267339
[x]
Attachment Details

Using a calculated column later in the query

Asked by Velio in MS SQL Server, Databases Miscellaneous, SQL Query Syntax

Tags: , , ,

Hi,

Please have a look at the query below, i want to have an extra column - Total, which is calculated by multiplying Volumes by the calculated Rate column. is this possible?
  Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
SELECT
  CASE 
    WHEN Volumes > 0 AND Volumes <= 100 THEN 7.6
    WHEN Volumes > 100 AND Volumes <= 500 THEN 8.6
    WHEN Volumes > 500 THEN 9.0
  END AS Rate,
  Volumes
  --need a [Rate] * [Volumes] AS [Total] type of column here.
FROM 
  Transactions
WHERE 
  ID = @ID
 
Loading Advertisement...
 
[+][-]03.25.2008 at 08:30AM PDT, ID: 21202817

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, Databases Miscellaneous, SQL Query Syntax
Tags: Microsoft, SQL Server, 2005, Transact-SQL
Sign Up Now!
Solution Provided By: ee_rlee
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628