How to fix this SQL Server error?

user9925928

My query throws an error

Incorrect syntax near '='.

Please tell me where I am doing wrong.

case 
   when proj.country_name = 'UK' 
      then proj.region = 'NE'
   when proj.Country_Name = 'Belgium' or proj.Country_Name = 'Germany' or proj.Country_Name = 'Netherlands' 
      then proj.region = 'CE'
   when proj.Country_Name = 'Spain' or proj.Country_Name = 'France' or proj.Country_Name = 'Italy' 
      then proj.region = 'SE'
   else proj.region
end as Region_NCC,

Thanks

Yogesh Sharma

That is invalid syntax case expression doesn't return value with column name :

case when proj.country_name = 'UK' then 'NE'
     when proj.Country_Name in ('Belgium', 'Germany', 'Netherlands') then 'CE'
     when proj.Country_Name in ('Spain','France', 'Italy') then 'SE' 
     else proj.region
end as Region_NCC

I have used IN clause instead of strange OR clause.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I fix the error 'Named Pipes Provider, error 40 - Could not open a connection to' SQL Server'?

How to fix SQL server JSON_VALUE path has '-' error

how to fix sql server page level corruption?

How to fix this query to avoid syntax error in SQL Server 2008

I am trying to store data in sql server but i run into an error which i dont know how to fix

How to fix error "String or binary data would be truncated" in SQL Server

How to fix the error with dev-server watch?

New to SQL-Server, How do i fix msg 8169 error?

SQL WHEN function - How to fix Syntax Error?

How to fix targeting error on Server 2016?

How to fix 'JSON text is not properly formatted. Unexpected character '\' is found at position 1.' error in SQL Server

How to fix an OLE DB error in SQL Server Data Tools

How to fix connectex error when trying to access SQL Server instance on Cloud SQL using SSMS via Proxy

how to fix an error in your SQL syntax;

How do I fix an error connecting to SQL Server: SSL Provider, error: 0 - The message received was unexpected or badly formatted

SQL Server : getting an error "Msg147, level15" Why do I get this error and how to fix it

How to fix have "Microsoft.VC80.CRT" error during install Microsoft SQL Server 2014?

What is the quic server error on go and how to fix it?

Is A Driver For SQL Server Corrupt, And How To Fix It If So?

How to Fix Error get node this example in sql?

How to Fix error in this example in sql?

How to fix '[Microsoft][SQL Server Native Client 10.0]String data, right truncation' Error with BCP

How to fix error 1052 relating to SQL alias

Flask server internal error, how to fix it

how to fix the SQL Error [1093] and Error [1064]?

How to fix this SQL Server query?

How can I fix this IF statement error in sql

How to fix TCP provider error 40 in SQL Server?

Why did I get this error in SQL Server ? How can I fix this?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive