Re: query

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 05/13/04


Date: Thu, 13 May 2004 11:29:15 +0200

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)


Relevant Pages

  • Re: need help to create query
    ... something I had to unlearn when I started doing SQL ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.programming)
  • Re: TSQL equivalent of VBA
    ... >in SQL? ... I presume that I need a CASE statement which I can write, ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.programming)
  • Re: query
    ... >>I have a column in an SQL table. ... >>can anyone advise me how to write a query to establish ... >Hi Freger, ... >Best, Hugo ...
    (microsoft.public.sqlserver.mseq)
  • Re: newest date
    ... >data set, in order to give it out in a new column 'newest date'. ... And I can't test my SQL, ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.programming)
  • Re: Stored Procedure
    ... Hi Phoon, ... from VB to SQL Server. ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.server)