Re: [SQLDownUnder] CASE STATEMENT


    [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
    • From: Damian Maclennan
    • Subject: Re: [SQLDownUnder] CASE STATEMENT
    • Date: Fri, 11 Mar 2005 09:12:35 +1100

    No
    
    The distinction to make here, is that in SQL, CASE isn't a statement,
    it's an Expression. It must return a value rather than controling
    execution flow.
    
    Damian
    
    
    
    On Thu, 10 Mar 2005 13:43:08 +1100, anthony <list@xxxxxxxxxxxxxxx> wrote:
    > thanks...so i cannot put a SQL statement under each when?
    > ________________________________
    > From: SQLDownUnderList@xxxxxxxxxxxxxxxxxxxxxx
    > [mailto:SQLDownUnderList@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
    > Victor.Isakov@xxxxxxxxxxxxxxxxxxxx
    > Sent: Thursday, 10 March 2005 1:40 PM
    > To: SQLDownUnder@xxxxxxxxxxxxxxxxxxxxxx
    > Subject: RE: [SQLDownUnder] CASE STATEMENT
    > 
    > 
    > To be a little picky, sorry Peter, I would recommend avoiding = for Column
    > Headings as it ain't ANSI, so:
    >  
    > SELECT 
    > CASE 
    > WHEN BankBalance > 0 THEN 'Rich' 
    > WHEN BankBalance = 0 THEN 'Neutral 
    > ELSE 'Broke' 
    > END AS MyFinancialPosition
    > ......
    > ________________________________
    > From: SQLDownUnderList@xxxxxxxxxxxxxxxxxxxxxx
    > [mailto:SQLDownUnderList@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Peter Busch,
    > Altosoft
    > Sent: Thursday,10 March 2005 1:36 PM
    > To: SQLDownUnder@xxxxxxxxxxxxxxxxxxxxxx
    > Subject: Re: [SQLDownUnder] CASE STATEMENT
    > 
    > 
    >  
    >  
    > SELECT MyFinancialPosition = 
    > CASE 
    > WHEN BankBalance > 0 THEN 'Rich' 
    > WHEN BankBalance = 0 THEN 'Neutral 
    > ELSE 'Broke' 
    > END
    > ......
    >  
    > or 
    >  
    > SELECT MyFinancialPosition = 
    > CASE BankBalance 
    > WHEN > 0 THEN 'Rich' 
    > WHEN = 0 THEN 'Neutral 
    > ELSE 'Broke' END
    > .....
    >  
    >  
    >  
    >  
    >  
    >  
    > ----- Original Message ----- 
    > From: anthony 
    > To: sqldownunder@xxxxxxxxxxxxxxxxxxxxxx 
    > Sent: Thursday, March 10, 2005 12:28 PM
    > Subject: [SQLDownUnder] CASE STATEMENT
    > 
    > How do i create a CASE statement in SQL with the same functionaility as this
    >  
    > select case Type
    > case 1
    >         ....some code
    > case 2
    >     .......some code
    > end select
    >  
    > AnthonySto unsubscribe to this list, please send a message back to the list
    > with 'unsubscribe' as the subject. Powered by mailenable.com - List managed
    > by http://www.readify.net to unsubscribe to this list, please send a message
    > back to the list with 'unsubscribe' as the subject. Powered by
    > mailenable.com - List managed by http://www.readify.net 
    > 
    > This message and any attachment is confidential and may be privileged or
    > otherwise protected from disclosure. If you have received it by mistake
    > please let us know by reply and then delete it from your system; you should
    > not copy the message or disclose its contents to anyone.
    > 
    > ==============================================================================
    > to unsubscribe to this list, please send a message back to the list with
    > 'unsubscribe' as the subject. Powered by mailenable.com - List managed by
    > http://www.readify.net to unsubscribe to this list, please send a message
    > back to the list with 'unsubscribe' as the subject. Powered by
    > mailenable.com - List managed by http://www.readify.net
    
    
    to unsubscribe to this list, please send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by http://www.readify.net
    
    
    



    (Click here for more information on the sqldownunder mailling list)