SQL to Split 1 Record into 2

Hi Guys,

Here is an example:
ID_NUMBER---STREET_DATE---NORMAL_PRICE---BASE_PRICE
001------------01/01/2006-------10.00--------------8.00

The output should be somewhat like this:
ID_NUMBER---STREET_DATE---CONDITION---RATE
001------------01/01/2006-------SRP--------10.00
001------------01/01/2006-------BSE--------8.00

The 3rd column CONDITION is contanst based on the Normal and Base Price.

I would appreciate any help.
Thanks.
asimahmed073100Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

adwisemanCommented:
Select ID_NUMBER, STREET_DATE, 'SRP' AS Condition, Normal_Price as Rate
FROM MyTable
UNION ALL
Select ID_NUMBER, STREET_DATE, 'SRP' AS Condition, Base_Price as Rate
FROM MyTable
order by ID_NUMBER, Condition
adwisemanCommented:
sorry, second recordset needed to be BSE

Select ID_NUMBER, STREET_DATE, 'SRP' AS Condition, Normal_Price as Rate
FROM MyTable
UNION ALL
Select ID_NUMBER, STREET_DATE, 'BSE' AS Condition, Base_Price as Rate
FROM MyTable
order by ID_NUMBER, Condition
Scott PletcherSenior DBACommented:
Or, to avoid two passes thru the main table:


SELECT id_number, street_date,
    type_of_price,
    CASE WHEN type_of_price = 'SRP' THEN normal_price ELSE base_price END
FROM tableName
CROSS JOIN (
    SELECT 'SRP' AS type_of_price
    UNION ALL
    SELECT 'BSE'
) AS types_of_price
ORDER BY id_number, condition DESC

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.