If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > CASE statement question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-13-03, 12:55
sTe810 sTe810 is offline
Registered User
 
Join Date: Feb 2003
Posts: 15
CASE statement question

hi,

Suppose I want to do the following:

DECLARE @num
SET @num = -1 /* initial value */

SELECT col1, col2,
CASE @num
WHEN -1 THEN ( [assign a value to @num], [return that value] )
ELSE @num
END AS 'num'
FROM T1

In English, I only want the @num variable to be calculated once but appear in every column of the SELECT result, since table T1 has many rows.

Greatly appreciate any help... thanks in advance!!
Reply With Quote
  #2 (permalink)  
Old 03-26-03, 12:50
alligatorsql.com alligatorsql.com is offline
Registered User
 
Join Date: Jul 2001
Location: Germany
Posts: 189
which database

Hello,

it looks like SQL Server ???? Is it true ?

Best regards
Manfred Peter
(Alligator Company GmbH)
http://www.alligatorsql.com
Reply With Quote
  #3 (permalink)  
Old 04-06-03, 20:29
sTe810 sTe810 is offline
Registered User
 
Join Date: Feb 2003
Posts: 15
Yes... it is SQL Server...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On