Arithmetic overflow error converting nvarchar to data type numeric in case query

I am trying to show the number of quotes won as a percentage of the total number of quotes in a time frame. For example. I have a total of 294 quotes and 173 of them are won. The result I am looking …

SQL case sensitive compare

I like to know with a CASE statement wether two fields are the same. I managed to do it with following query but I wonder if there is a better approach? I just want the ‘=’ to do a case sensitive …

SQL: Change the value of a column in function of another

I get a table from SQL that I put whitin a winform’s datagridview. I just want to change the value of my last column in funtion of another. Here is the example: I have 4 columns : ID / Price / …

Is there the ability for SQL to take a value, use logic, and result a different value

This may be a silly question, but I’m trying to essentially take a value that’s in a field and IF contains “Tele” THEN result Televideo. Or it might be better: IF other than “Office&…

Case expression with Boolean from PostgreSQL to SQL Server

I am translating a query from PostgreSQL to SQL Server. I didn’t write the query in PostgreSQL and it’s quite complicated for my knowledge so i don’t understand every piece of it. From my understand: …

How i want make 3 rows of the same primary key into 1 row by checking and choose its value using case

For example here, from this table key | status 1001 | A 1001 | D 1001 | C the hierarchy will be C>D>A If the the stats contain C as the value, the person status will become C in one row. …

Why is my case statement not returning the value in my “else” clause?

I have this section of code and my ELSE is not working. It should return ‘UNKNOWN’ but I am still seeing NULLs in my results. What is going on? case when t2.NEURO_GRP_2 is not NULL …

How to use CASE WHEN in PostgreSQL without adding values to aggregation and GROUP BY?

I need to take one timestamp if my condition is right and other value, if not. I made such condition: CASE WHEN tr.type = ‘deposit’ THEN tr.timestamp::date ELSE tr.status_last_change_timestamp::date …

How to update row by id using case?

Is it possible to update by id other row values? I try like this But nothig.. UPDATE era SET id = CASE WHEN id = 3 THEN gender = ‘Female’–or maybe it is possible to call insert command here? …

Why am I getting a CASE error when in Data Studio?

I’m trying to convert a four-digit numerical code to a four-digit (one letter + 3 numbers) with a CASE clause in Data Studio. The four-digit numerical code is being pulled out of a Sheets file. I keep …