Monday, March 26, 2012

query

Hi
I have a column in an SQL table. the column is all numeric
data from 100 to more than 400. I would like to convert
the data in this column to something else. e.g.
micro = <200
mini = between 200 and 300
midi = between 300 and 400
full > 400
can anyone advise me how to write a query to establish the
above task.
Thank you.
Freger
On Thu, 13 May 2004 02:18:23 -0700, Freger wrote:

>Hi
>I have a column in an SQL table. the column is all numeric
>data from 100 to more than 400. I would like to convert
>the data in this column to something else. e.g.
>micro = <200
>mini = between 200 and 300
>midi = between 300 and 400
>full > 400
>can anyone advise me how to write a query to establish the
>above task.
>Thank you.
>Freger
Hi Freger,
This can be accomplished using CASE:
SELECT CASE
WHEN (NumericData <= 200)
THEN 'Micro'
WHEN (NumericData <= 300)
THEN Mini'
WHEN (NumericData <= 400)
THEN 'Midi'
ELSE 'Full'
END AS ColumnAlias
FROM YourTable
Replace column and table names as appropriate.
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)
|||Thank you, Hugo.[vbcol=seagreen]
>--Original Message--
>On Thu, 13 May 2004 02:18:23 -0700, Freger wrote:
numeric[vbcol=seagreen]
the
>Hi Freger,
>This can be accomplished using CASE:
> SELECT CASE
> WHEN (NumericData <= 200)
> THEN 'Micro'
> WHEN (NumericData <= 300)
> THEN Mini'
> WHEN (NumericData <= 400)
> THEN 'Midi'
> ELSE 'Full'
> END AS ColumnAlias
> FROM YourTable
>Replace column and table names as appropriate.
>Best, Hugo
>--
>(Remove _NO_ and _SPAM_ to get my e-mail address)
>.
>

No comments:

Post a Comment