Most voted "case" questions
50 questions
Sort by count of
-
10
votes2
answers413
viewsUpdate with Case When you need Where?
UPDATE bethadba.FOFILHOS SET CPF = CASE WHEN CODI_EMP = 61 AND I_EMPREGADOS = 156 AND i_filhos = 1 THEN '00551366133' WHEN CODI_EMP = 57 AND I_EMPREGADOS = 290 AND i_filhos = 1 THEN '00636170993'…
-
5
votes1
answer2819
viewsUsing Switch Case for Ranges
My teacher passed an exercise in which we should use the cases of a switch to treat intervals, he strictly said that we should use the switch and we cannot use if and neither while/do. I’ve tried…
-
3
votes1
answer6005
viewsUsing Case When with Leftjoin
I am mounting a proc, but depending on the value of a parameter, I would like left Join to be different. I tried the kerys below: That works, but the else as null or even without the else, if the…
-
3
votes2
answers490
viewsUsing case in null field
I have the following structure tb_boletim: |Cod|boletim|dt_enviado| | 1 | N | NULL | | 2 | S |24/08/2018| | 3 | S | NULL | | 4 | S |23/08/2018| | 5 | S |23/08/2018| | 6 | S | NULL | | 7 | N | NULL |…
-
3
votes1
answer62
views -
2
votes1
answer697
viewsFor inside a Java Switch
Good night, I wonder if there is a way to declare a 'FOR' within a SWITCH CASE in Java because Netbeans is making an error right here. I’m trying to make an application to perform a guessing game…
-
2
votes1
answer26028
viewsCompare NULL using CASE SQL
I have to recover 2 fields in this query (number of projects and the management that runs such a project). This query will be used to generate a report in JASPER and it does not display field with…
-
2
votes2
answers663
viewsRuby - comparison of values between a range or greater than, less than
I’m starting to study programming so, here’s a good beginner question. I took the test below to learn about case in Ruby, current_time = ARGV.first.to_i case current_time when 0..45 then puts('First…
-
2
votes1
answer64
viewsGroup result through a conditional
I wonder if in Mysql or any other Bank you have the possibility to use GROUP BY with a conditional. I will try to explain I have a status column that can have the value true and false, would like to…
-
2
votes3
answers89
viewsproblem with select case
I am selecting with case comparing different status of the same field and counting them in separate columns. The problem is that the first column is NULL until the list of the second finishes…
-
2
votes1
answer147
viewsGroup empty case when sql cells
I am making a query in the database to know in which branch the customer paid a installment and what is the normal value and interest that were paid. The value of the tranche is transaction 3 at the…
-
2
votes2
answers55
viewsWhy do if or case tests not work in this subquery?
I am trying to run the following subquery within a view: (SELECT if(idnotas > 0, "não", "sim") FROM notas WHERE vendas_idvendas = p.vendas_idvendas ORDER BY idnotas DESC LIMIT 1 ) as…
-
2
votes1
answer68
viewsCase/when, help us
I did a search and I couldn’t find a logic to use in this case. the table columns are: COD_DO_USUARIO_ONE | COD_DO_USUARIO_TWO | TEXT I’m basically trying to put together a code that can identify…
-
1
votes1
answer110
viewsHow to check if something has been passed to the php page?
It is even difficult to ask because I do not know if this is right, but I will try to explain it in the best way possible. I have a page where I will use the php case switch to decide the action…
-
1
votes1
answer607
viewsTo select a switch/case statement each click on the button
I would like to make list(Gem) of A-Z. A detail, based on breaking/dividing this list(Gem) alphabet into parts: Although my difficulty is in, after being clicked on the button, the same bring up the…
-
1
votes2
answers1006
viewsISNULL in a Case When
I’m making a select using the CASE WHEN in Sql Server, so that the existence of a record is checked, if it exists, it selects in a table, otherwise it selects in another table, but the two can…
-
1
votes1
answer101
viewsMysql case returning type blob
I created a search query in Mysql and using case within it. The problem is that by returning the value of the column that is of the whole type, the value comes with the answer blob. Follow SELECT…
-
1
votes1
answer812
viewsHow to use CASE WHEN in an IN statement?
In a query I am gathering data on representatives, customers and sellers. Some representatives have sellers, who in turn have customers. These cases are exceptional as clients are directly linked to…
-
1
votes1
answer433
viewsIs there any way to use logical operators with CASE/WHEN?
I am trying to use logical operators with CASE/WHEN in SQL but I am having difficulties, I need to present an answer if the result of the operation is less than 0 and another result for when the…
-
1
votes1
answer8375
viewsUse 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…
-
1
votes1
answer187
viewsDifference 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 is not displayed even result? Query that returns me the expected result:…
-
1
votes1
answer66
viewsProblems in String and Case
I’m a beginner in programming for a little while and I have a college task in which I must create a registration system that receives the entries the customer data and then another option that…
-
1
votes2
answers2342
views -
1
votes1
answer113
viewsQuery in sql server with different value depending on some variables
Good afternoon I have the following query: select distinct(T.Grupo) 'Grupo', MAX(G.Descricao) 'Grupo', sum(E.QtdCat*S.FactConvEst) 'M2 cativos' from EncLin as E INNER JOIN Stock as s on…
-
1
votes2
answers235
viewsCase in Where using SQL Server
I have the following code that lists certain trade agreements. You have the Yes or No option. DECLARE @Opcao VARCHAR(7) SET @Opcao = 'S' SELECT * FROM BLA BLA BLA WHERE ((('{Opcao}' = 'S') AND…
-
1
votes1
answer147
viewsSwitch command does not work and shows no errors
I’m trying to solve the following exercise: Devise an algorithm that assists in controlling a cattle farm that has a total of 2,000 head of cattle. The database consists of a set of structures…
-
1
votes1
answer132
viewsswitch case to work when migrating from PHP 5.6 to 7.0
I have a news system running with PHP 5.3 and would like to upgrade it to at least 5.6. I have been using Php_codesniffer-master and Phpcompatibility-master to assist me in the change. Most of the…
-
1
votes0
answers69
viewsHow to sum up an Oracle select case
I am trying to make a sum in a select case, but apparently it is not valid, the following error appears " ORA-01858: a non-numeric Character was found Where a Numeric was expected". when I remove…
-
1
votes1
answer90
viewsUsing Case or if
I’m a beginner in SQL and I’m having difficulty using the CASE WHEN. I have a table called CRM_PROCESSO, in which you have a column with the option of Status, but the answer to this status is…
-
1
votes1
answer378
viewsOracle Where case
I need to create a condition in the where according to a boolean. If boolean = true then I will select the lines with higher end values than expected (ConfirmedVolume > ExpectedVolume, etc) if it…
-
1
votes2
answers144
viewsCASE WHEN in Where clause and with THEN with more than 1 return value
Hello. I have an application for assembly of queries, in which I pass the parameters in the clause "Where". Only I came across a situation where I need to use CASE and in the THEN clause a range of…
-
1
votes2
answers141
viewsProcedure with CASE in the WHERE clause
Well my doubt is this, I’m beginner in sql serves, i am running a trial and in it using the CASE method the following code shows what I am doing: ALTER PROCEDURE [dbo].[STP_S_Cliente_Busca]( @Busca…
-
0
votes2
answers74
viewsChecking column fill with CHECK
I am creating the BD of my TCC and the table Clients is: create table clients( id serial primary key, name varchar(255), cpf varchar(11), cnpj varchar(14), .... I thought of doing a CHECK limiting…
-
0
votes2
answers728
viewsSwap elseif code for switch case
I’m having trouble modifying a code I made in else if for switch case. I’m not getting the code to work, he gets values and operation by $_GET and does the selected operation: I leave the code here:…
-
0
votes0
answers964
viewsCase nestled inside another case
I’m very doubtful about CASE NESTED I have to perform an interest calculation that depends on some variables and I’m not able to build this case, so I need your help to assemble it. 1º IF…
-
0
votes2
answers950
views -
0
votes1
answer35
viewsColor recognition with switch/case
In my code, I’m making a map in which one pixel for colored x, then the Sprite x will be put in it, example: int pixelAtual = pixels[xx + (yy * map.getWidth())]; tiles[xx + (yy * WIDTH)] = new…
-
0
votes1
answer51
viewsSQL CASE command
I’m trying to select only 5 characters from the field description, tried several ways and it doesn’t work, the eating I’m giving is this: SELECT description = CASE WHEN LEN(description) > 5 THEN…
-
0
votes1
answer30
viewsConcatenate lines into one
Good afternoon, I need to unify some data, when I bring this so: id 2017 2017-LOJA 2018 2018-LOJA 1 n n s s 1 s s n n Would like so: id 2017 2017-LOJA 2018 2018-LOJA 1 s s s s consultation I made:…
-
0
votes2
answers198
viewsConditional help in SQL WHERE
Come on, guys, I’m putting together an SQL query. In this query, the field SD1010.D1_TES can assume N values, but if this field is equal to empty, I need one more restriction to be applied…
-
0
votes1
answer30
viewsRemove SQL CASE parameter agreement results
As follows the query below, I need to remove from the SQL query the results that have the field CLIENTE_UNICO EQUAL TO 'MULTIPLE PURCHASES IN THE PERIOD'. SELECT NFE.CD_CLIENTE AS "COD. DO CLIENTE",…
-
0
votes1
answer39
viewsgroup each period per month
I’m doing this consultation, but I’m not able to group each period per month, the previous year. For each month of the year preceding the current year, return the amount of parked cars per period…
-
0
votes1
answer51
viewsConcatenate values with condition (case)
Good evening! I’m new to the programming. I have the code below in a CTE that counts the number of subscribers in each area. In the main consultation I see which area has the largest amount of…
-
0
votes1
answer58
views -
0
votes1
answer24
viewsSelect case with subselect and Join
I need to make a select case with a subselect, is it possible? If yes please let me know where I am going wrong, else what I can do in this case: SELECT m.arquivoordemmov, m.contadoragentemov,…
-
-1
votes1
answer139
viewsJava: Problem with Substring
I created a program to translate musical notes from a site to a more readable format, it receives and analyzes every two digits of a string looking for them (as key) within a hashmap, if found, the…
-
-1
votes2
answers52
viewsPython creating conditions or loop
(I wanted something that when he entered one of the levels more questions would appear and in case he wants to leave press a key) print("Agora ira começar um joguinho. \n") print("Comece digitando…
-
-2
votes2
answers302
viewsWhen I run the commands on Switch Case, does it end instead of going back to Menu?
int main(){ int tensao, corrente, resistencia, potencia, tempo, cargaeletrica, trabalho, i; printf("\nPara calculo de Tensao(resistencia*corrente) digite 1\n\nPara calculo de…
-
-4
votes1
answer153
viewsinsert data with ajax and switch in php
I have a php script that I use GET to take a parameter from url and move on to a php switch and perform a certain function. That one script works perfectly without errors but how to use it with…
-
-4
votes2
answers104
viewsError in "break" in C++ code prevents compilation
Follows code: #include <iostream> using namespace std; int main() { float n1, n2; int s; float resul; cout << "Digite um número para começar" << endl; cin >> n1; cout…