vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| SELECT CASE WHEN Assignment_Type = 'C' THEN 'Com' ELSE 'Donot Know' FROM ASSIGNMENT When I try to use CASE WHEN, it gave me error [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'FROM'. What did I do wrong? Thanks "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message news:24GdncWmqJeLKfzcRVn-vg@giganews.com... > Use CASE > > -- > David Portas > SQL Server MVP > -- > > |
| |||
| > What did I do > wrong? You didn't read-up on the syntax first! My reply was intended as an indication of something you should look up. You'll find Books Online is a great resource if you refer to it occassionally :-) SELECT CASE WHEN Assignment_Type = 'C' THEN 'Com' ELSE 'Do not know' END FROM ASSIGNMENT or SELECT CASE Assignment_Type WHEN 'C' THEN 'Com' ELSE 'Do not know' END FROM ASSIGNMENT -- David Portas SQL Server MVP -- |
| |||
| David, Sorry, I don't have books online. The examples I found on the site, none of them used "END" in the statment. Thanks a bunch! ^_____^ N "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message news:5MGdne_kiKNeKvzcRVn-gw@giganews.com... > > What did I do > > wrong? > > You didn't read-up on the syntax first! My reply was intended as an > indication of something you should look up. You'll find Books Online is a > great resource if you refer to it occassionally :-) > > SELECT CASE WHEN Assignment_Type = 'C' THEN 'Com' ELSE 'Do not know' END > FROM ASSIGNMENT > > or > > SELECT CASE Assignment_Type WHEN 'C' THEN 'Com' ELSE 'Do not know' END > FROM ASSIGNMENT > > -- > David Portas > SQL Server MVP > -- > > |
| |||
| Get BOL here: http://www.microsoft.com/sql/techinf...00/default.asp -- David Portas SQL Server MVP -- |
| |||
| N wrote: > What is the function in SQL that works like DECODE in Oracle?" > > > > Thanks, > > N As you know CASE is not the same as DECODE ... but SQL Server hsa no functionality equivalent to DECODE so you will have to adapt CASE to do the job. -- Daniel A. Morgan University of Washington damorgan@x.washington.edu (replace 'x' with 'u' to respond) |
| |||
| Daniel Morgan wrote: > N wrote: > >> What is the function in SQL that works like DECODE in Oracle?" >> >> >> >> Thanks, >> >> N > > > As you know CASE is not the same as DECODE ... but SQL Server hsa no > functionality equivalent to DECODE so you will have to adapt CASE to > do the job. How is DECODE different than "simple CASE"? (Other than that DECODE is a function and CASE an expression, of course...) Cheers Serge |
| |||
| You can also find the books online online at http://msdn.microsoft.com/library/de...server2000.asp Open up the SDK Documentation tree item. Muhd "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message news:5aOdncEAVOgnX_zcRVn-tA@giganews.com... > Get BOL here: > http://www.microsoft.com/sql/techinf...00/default.asp > > -- > David Portas > SQL Server MVP > -- > > |
| ||||
| "Daniel Morgan" <damorgan@x.washington.edu> wrote in message news:1096932539.547042@yasure... > N wrote: > > What is the function in SQL that works like DECODE in Oracle?" > > Thanks, > > > > N > > As you know CASE is not the same as DECODE ... but SQL Server hsa no > functionality equivalent to DECODE so you will have to adapt CASE to > do the job. > -- > Daniel A. Morgan > University of Washington > damorgan@x.washington.edu > (replace 'x' with 'u' to respond) > OK, then, what does DECODE do? |
| Thread Tools | |
| Display Modes | |
|
|