Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Problem in formatting result set

Author  Topic 

chamank
Starting Member

2 Posts

Posted - 2010-09-08 : 11:39:43
I am having problem in displaying the result set in the required format.


Background Info:
User selects main date and number of different dates (no fixed number of dates – dynamic) for comparison

In the following example, the main date is 20100803 and 2 selected date’s .i.e. 20100519 & 20100729 but please note this is user defined and we can have more than three dates.
Ideally, I would like to have just one record per ISIN showing main date, main price and price diff for each selected date.

CREATE TABLE dbo.PricingData
(
[ISIN] [varchar](50) NOT NULL,
[MainDate] [varchar](50) NOT NULL,
[SelDate] [varchar](50) NOT NULL,
MainPrice [float] NOT NULL,
SelPrice [float] NOT NULL,
PriceDiff [float] NOT NULL
)


INSERT INTO PricingData
VALUES('AU0000CBAHL7','20100803','20100519',101.19, 101.73,-0.54)

INSERT INTO PricingData
VALUES('AU0000CBAHL7','20100803','20100729',101.19, 101.19,0.0069)


SELECT * FROM PricingData

--Current Result:
ISIN MainDate SelDate MainPrice SelPrice PriceDiff
AU0000CBAHL7 20100803 20100519 101.19 101.73 -0.54
AU0000CBAHL7 20100803 20100729 101.19 101.19 0.0069

--Required Result:
ISIN 20100803 20100519 20100729 – Column names
AU0000CBAHL7 101.19 -0.541 0.0069

I would appreciate your help on this matter.

Any questions please let me know.

Thanks in advance

Cheers
Chaman

sql-programmers
Posting Yak Master

190 Posts

Posted - 2010-09-09 : 08:11:10
ISIN 20100803 20100519 20100729 – Column names
AU0000CBAHL7 101.19 -0.541 0.0069

What the "Column names" means , Explain in detail

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

chamank
Starting Member

2 Posts

Posted - 2010-09-10 : 09:28:09
Sorry for the confursion.
Just to indicate that line as Column names.
Please ignore "Column names".

ISIN 20100803 20100519 20100729
AU0000CBAHL7 101.19 -0.541 0.0069
Go to Top of Page
   

- Advertisement -