473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

T-SQL Pivot type of problem plus AVG

Hi,
I have two tables MEASUREMENTS AND PARAMETERS. I want to be able create a row in PARAMETERS from the data in MEASUREMENTS. The data in PARAMETERS is an average for each year. This is a 'BULK INSERT' type procedure.

For example:

MEASUREMENTS:
IDNO, MEASDATE, MEASTYPE, VALUE1, VALUE2, VALUE3, VALUE4
1, 1/2/2004, WT, 78
1, 1/12/2004, WT, 95
1, 1/12/2004, HT, 176
1, 1/2/2004, CHOL, 6.7, 1.5, 1.12, 4.2
1, 1/12/2004, CHOL, 4.1, 1.2, 1.13, 2.2
.
.
.

Creating:

PARAMETERS:
IDNO YEARAVERAGE HEIGHT WEIGHT TOTALCHOL TRI HDL LDL
1, 2004, 176, 86.5, 5.4, 1.35, 1.125, 3.2
.
.
.

In this example When MEASTYPE = CHOL VALUE1 maps to TOTALCHOL, VALUE2 maps to TRI, VALUE3 maps to HDL & Value4 maps to LDL.
I have 10 diferent MEASTYPE CODES each with a variable number of values.

Can this be achieved with T-SQL via a stored procedure or should I just use a script to acieve the right outcome?
Any opinions or thoughts would be most welcome.
Jun 17 '07 #1
1 1501
kestrel
1,071 Expert 1GB
I am moving this to the SQL Forum.

--
Kestrel
Jun 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lukelrc | last post by:
Hi all. I'm having trouble connecting to my sql server database correctly beacause of value type problems, specifically the date fields. When i try and run the page i get the follwoing error: ...
3
by: kieran | last post by:
Hi, I have a form which is submitting into a sql server db. i have one of the fields set to ntext which says length of 16. when i insert info, it only sumbits about a paragraph and when i pull...
1
by: icedac | last post by:
I have some questions about template and c++ itself. ///////////////////////////////////////////////////////////////////////// q1) see follow c++ code, and compile. it's works only IntelC++8.1...
1
by: Vinay Jain | last post by:
Hi I am newbie so this problem may be too simple to be asked.please help me if any new thing to be added in following: I want to use user defined data type in User_Type(n) way.... I created...
6
by: Picho | last post by:
Hi all. I have a webservice and a windows app. both of them reference the same class library called WebServiceTest.Core that defines a class called Class1. the webservice exposes a method...
0
by: Doranj00 | last post by:
Hello Everyone, Its been awhile since developing SQL code and I have a dilemma. Now, I can think of several ways to get what I need, BUT the important thing is that I need the optimized way to...
6
by: cppnow | last post by:
Hello. I have a strange conceptual problem I'm trying to think about. I would like to build a library that allows the user to do the following: 1) User defined types: The user defines their...
0
by: ravindarjobs | last post by:
Hello friends, I am using ms access 2003, and Vb6. i am displaying a table in a form as pivot table (following "Auto Form: Pivot Table" Wizard) Usually i select the items i want to be...
17
by: irfan200x | last post by:
Folder Option Hi All, I have the new type problem in folder option where should i get this problem through Flash Drive Plug into USB port and its Shows ON and OFF in the Windows XP SP2. and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.