Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2009, 04:08 PM
Authorized User
 
Join Date: Sep 2006
Posts: 73
Thanks: 6
Thanked 0 Times in 0 Posts
Default Calculation In Select Statement

Hello All,

I am looking for a way to perform a calculation on the results of weight and height. I need see if there is a result for the height and weight for a person on the same date since they are entered at the same time. If so, then I need to perform the calculation (weight/(height*height)) x 703.

Any help would be appreciated.

Thank you.

Code:

USE TempDB
GO

CREATE TABLE dbo.HeightWeight
(      Name          VARCHAR(50),
        Date          DateTime,
        Description   VARCHAR(50),
        Result        VARCHAR(20)
)
INSERT INTO HeightWeight
(Name,Date,Description,Result)
SELECT 'Test1','2009-05-01','Height','60' UNION ALL
SELECT 'Test1','2009-05-01','Weight','175' UNION ALL
SELECT 'Test1','2009-05-02','Height','60' UNION ALL
SELECT 'Test1','2009-05-02','Weight','176' UNION ALL
SELECT 'Test2','2009-05-03','Height','65' UNION ALL
SELECT 'Test2','2009-05-03','Weight','190' UNION ALL
SELECT 'Test3','2009-05-04','Height','68' UNION ALL
SELECT 'Test3','2009-05-04','Weight','180' UNION ALL
SELECT 'Test4','2009-05-05','Height','63' UNION ALL
SELECT 'Test4','2009-05-05','Weight','185'
 
Old May 18th, 2009, 08:33 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Answered in other thread.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculation In Select Statement eusanpe SQL Server 2005 8 May 19th, 2009 08:35 PM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Calculation using if...then...else statement oliver ASP.NET 1.0 and 1.1 Basics 2 March 7th, 2007 07:29 PM
Skewness calculation in SQL statement akmhasan Oracle 0 July 13th, 2003 04:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.