October 18, 2004 at 12:46 pm
Hi
I have a table which has values
Description Value
Tiering N/A
Strategic Overview N/A
Tier Pricing Report In Progress
Store Pricing Report N/A
Price Implement Done
Tracking Report N/A
I need a query which would have the result like
Tiering StrategicOverView TierPricing StorePricingReport
N/A N/A In Progress N/A
How could i get this?
Thanks,
Sridhar!!
October 18, 2004 at 2:21 pm
SELECT MIN(CASE Description WHEN 'Tiering' THEN Value ELSE NULL END) AS Tiering,
SELECT MIN(CASE Description WHEN 'Strategic Overview' THEN Value ELSE NULL END) AS StrategicOverview,
SELECT MIN(CASE Description WHEN 'Tier Pricing Report' THEN Value ELSE NULL END) AS TierPricing,
SELECT MIN(CASE Description WHEN 'Store Pricing Report' THEN Value ELSE NULL END) AS StorePricingReport
FROM YourTable
--
Adam Machanic
whoisactive
October 18, 2004 at 3:05 pm
Thanks Adam,
That worked.
Sridhar!!
October 19, 2004 at 11:28 am
hey sridar
could u plz explain how u solved the pblm.i did not understand. i get error when i did the same
thanx
Rajiv.
October 19, 2004 at 1:35 pm
October 20, 2004 at 4:09 am
Hey Rajiv,
u will get it very clear with following query.It's same as above but slight change.
SELECT MIN(CASE Description WHEN 'Tiering' THEN Value ELSE NULL END) AS Tiering,
MIN(CASE Description WHEN 'Strategic Overview' THEN Value ELSE NULL END) AS StrategicOverview,
MIN(CASE Description WHEN 'Tier Pricing Report' THEN Value ELSE NULL END) AS TierPricing,
MIN(CASE Description WHEN 'Store Pricing Report' THEN Value ELSE NULL END) AS StorePricingReport
FROM YourTable
Thanks
Yuvraj
October 20, 2004 at 9:47 am
Good catch Yuvraj... I was too quick on the copy and paste, I'm afraid!
--
Adam Machanic
whoisactive
October 24, 2004 at 7:47 am
hey adam and yuvraj
thanx for all ur efforts. sorry for not replying for a long time.
my doubt::
what is that "min( )" doing there?
when i used it...i got error.
select * from reg
regis rname
----------- --------------------
1234 a
5678 b
8901 c
select (select case when rname='a' then regis end ) as a,
(select case when rname='b' then regis end ) as b,
(select case when rname='c' then regis end) as c
from reg
a b c
----------- ----------- -----------
1234 NULL NULL
NULL 5678 NULL
NULL NULL 8901
now how to avoid this null values???
i neeed to get it as
a
October 24, 2004 at 7:54 am
hey all
now i got it....sorry for the trouble!!!
now i understand u Yuvraj.....also the function of "min" is clear.anything min or max would work...
thanx a lot....
Rajiv.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply