Questions tagged as 'case'

1
answer

Can you use logic operators with CASE / WHEN?

I'm trying to use logical operators with CASE / WHEN in SQL but I'm having difficulties, I need to give a response in case the result of the operation is less than 0 and another result for when the operation is > = 0 It makes a mistake if...
asked by 12.02.2018 / 19:46
1
answer

Use CASE in a WHERE clause

I need to use a condition within a filter parameter in a report. Basically the rule is determined by a vachar field that the value of it is 'T' or 'P'. I tried a solution like below but it did not work very well. The rule is, if the field is...
asked by 11.04.2018 / 20:19
1
answer

Using Case or if

I am a beginner in SQL and am having difficulty using CASE WHEN . I have a table called CRM_PROCESSO , in which there is a column with the Status option, but the answer for this status is numeric, being 1 - Aberto ,...
asked by 12.09.2018 / 14:16
2
answers

Case in Where using SQL Server

I have the following code that lists certain business agreements. You have the Yes or No option. DECLARE @Opcao VARCHAR(7) SET @Opcao = 'S' SELECT * FROM BLA BLA BLA WHERE ((('{Opcao}' = 'S') AND NFDataEmis BETWEEN lme.LogM...
asked by 21.06.2018 / 22:19
1
answer

Switch command does not work and does not display errors

I am trying to solve the following exercise: Elaborate an algorithm that assists in the control of a cattle farm that has a total of 2000 head of cattle. The database is formed by a set of structures (records) containing the following fields for...
asked by 12.05.2018 / 02:57
2
answers

ISNULL in a Case When

I am doing a select using CASE WHEN in Sql Server, so it is done checking the existence of a record, if it exists, it makes select in a table, otherwise it makes select in another table, however, the two can return null. Something like th...
asked by 24.10.2017 / 21:21
1
answer

How to check if something was passed to the php page?

It's even hard to ask because I do not know if it's okay, but I'll try to explain it as best I can. I have a page where I will use the php switch case to decide the action according to what is passed. However, if the page is only triggered witho...
asked by 14.02.2016 / 01:42
1
answer

Problems in String and Case

I'm a newcomer to programming recently and I have a college assignment where I have to create a registration system that receives input from customer data and then another option that prints the information on the screen. / p> But I'm having t...
asked by 22.10.2017 / 22:25
1
answer

Difference between normal avg and using case when in MySQL

I have two queries that are supposed to give the same result, however it is not happening. Can someone explain to me why it does not show the same result? Query that returns the expected result: SELECT id, ROUND(AVG(SinalGPS), 4...
asked by 10.02.2017 / 18:29
1
answer

How to use CASE WHEN in an IN statement?

In a query I am collecting data on representatives, customers and vendors. Some representatives have salespeople, who in turn have customers. These cases are exceptional because the clients are linked directly to their representatives....
asked by 08.09.2016 / 14:47