Posts by rLinhares • 7,797 points
331 posts
-
0
votes1
answer45
viewsA: Create a C function, which searches how many times a letter appears in a string
You are not going to variable aux by reference, so the value is not updated in main. void contador(char palavra[], char letra[], int *aux){ .. contador(palavra, letra, &aux); considering the…
-
0
votes1
answer26
viewsA: UPDATE in two tables at the same time
You need to separate the changes from each table: UPDATE tb_estoque SET id_cti = '004', cfop = '5102' WHERE id_estoque = 1; UPDATE tb_est_produto SET cod_ncm = '11111111', cst = '020' WHERE…
-
2
votes1
answer25
viewsA: Mergesort Liguagem C
From what I understand, this is your current comeback: 1, 8, 7, 8, 3, 3, 7, 5 So what you need to do is instead of just printing "number, ", you print the text you need: printf("Loja %d: %d\n", i,…
-
-1
votes1
answer34
viewsA: Java conditional
Your method must return a string. It is printing in the method itself instead of returning the text as a result. String situacao( ) { String retorno; if (icmsResidencial() <= ICMS1) { retorno =…
-
0
votes2
answers33
viewsA: How to search multiple columns together with max() SQL (Mysql)
You can make a subconsultation to first load the id_historico which will be displayed; with this, you can click on select the data (id_local and id_situation) of that specific item, restricting that…
-
0
votes2
answers90
viewsA: SQL - Integer and Decimal Number Conversion
Try to apply a CAST() at the consultation, specifying that three decimal places: SELECT cdempresa ,nmempresa ,cdproduto ,nmproduto ,CAST(qtfornecedor AS DECIMAL(10,3)) as qtfornecedor ,unidade…
-
0
votes1
answer23
viewsA: How to sort a query listing using curl_setopt_array?
You can do this using the array_sort() of php, where it is possible to clarify which is the ordering field: //array_sort(array_a_ser_ordenado, campo_de_ordenacao, ordem_escolhida) foreach…
-
-1
votes2
answers92
viewsA: Problem in SQL search
One way to do this control is, instead of two joins with the table of historical, bring the approved/disapproved control of the where, adding up (sum) in accordance with the concept - control made…
-
1
votes1
answer46
viewsA: SQL : Insert if Not Exist
You can add a WHERE to his insert making this check, as in that reply: ... new SqlCommand( "INSERT INTO TableName (param1, param2, param3) " + "VALUES (@param1, @param2, @param3) " + "WHERE NOT…
-
1
votes1
answer18
viewsA: How can I count the number of Records in Mysql?
Just remove the grouping of the query, ie, take that chunk out of the code. GROUP BY PEDIDO.COD_PEDIDO I suggest you take a look at how the GROUP BY. According to comment here in the reply, you need…
-
1
votes1
answer27
viewsA: GROUP BY TIME type field in Mysql
In the Mysql you need to "explain" how the grouping will be; I believe the most practical way is to define the date format in the select and using in group by country (link reference): SELECT…
-
1
votes1
answer36
views -
0
votes2
answers41
viewsA: Varchar operation in SQL 2014
As suggested in comment, to have the difference between two dates in months, you just need to change the "datepart", which is the first function parameter datediff(). SELECT *, DPD = datediff(day,…
-
1
votes1
answer21
viewsA: Group By - Aggregation error?
When you use the Group By, all columns that will be unique in select should be used for grouping. For example, if you want to know how many students are the same age and live in the same country,…
-
1
votes1
answer20
viewsA: SQL to group records
As commented, I believe that the ideal in the solution is even with subconsulta, similar to this other answer of ONLY. //inner join SELECT v1.RA, v1.Placa, v1.Data_Out AS Data_Saida FROM…
-
0
votes2
answers40
viewsA: Manual String Breaking in JAVA
I believe the problem may be about method equals(); this method compares the whole object, not just the value, as is its idea (for example, "home" would equal "home"). You could overwrite the method…
-
0
votes1
answer167
viewsA: Show F(n) of the Algorithm sequence of Fibonacci
Considering that all your code is correct, to print only the last value, you just need to take the command from inside the loop and put it after the loop. With this, you will only print the final…
-
0
votes1
answer21
viewsA: How to use while to catch all lines
From what I understand you want to press $configuracao the table data. Therefore, I believe that it would not be possible to dynamize the column identifier (which will be the position vector). You…
-
0
votes1
answer18
viewsA: Import description from another table
Wouldn’t be the case just you change the return field? SELECT COUNT(*) AS categorias_total, v_lctos_despesa.desc_categorias --valida o nome do campo FROM 'v_lctos_despesa' INNER JOIN categorias ON…
-
3
votes1
answer64
viewsA: How to count how many records there are in a Onetomany relation?
I believe I should count "backwards": SELECT b.chave, COUNT(b.chave) FROM a INNER JOIN b ON a.chave = b.chave GROUP BY b.chave How you need to know how many occurrences there are in the table B,…
-
1
votes1
answer31
viewsA: How to exclude a data from one or more tables
To delete more than one table, you need join together all of them. DELETE admissao_dominio, admissao, bancarios/*, boas_vindas, documentacao, exame_admissional, gestao, interno, parametros_captacao,…
-
1
votes1
answer57
viewsA: Error executing a subquery in sql server
I think the best way to do that is by not using the having. Since it’s only bringing one field, you can leave the filter on where even: SELECT MAX(PFHSTFER.DTFIMPERAQUIS) FROM PFHSTFER WHERE…
-
1
votes1
answer440
viewsA: Include date/time field in postgres (Zend)
According to that answer in the SOEN, you should keep field as string, and when loading the value, convert it to timestamp. That’s because the guy timestamp takes the standard seat format, not as…
-
1
votes1
answer32
viewsA: Error #1111 - mysql
In mysql, you can use the LIMIT: SELECT COUNT(endereco_completo), bairro FROM tend_endereco INNER JOIN tend_bairro ON tend_bairro.id_bairro = tend_endereco.id_bairro WHERE tend_bairro.id_cidade =…
-
0
votes1
answer26
viewsA: Sql Exec Problemas
By the structure of the code and by tags of the question, you are doing all this in sql even, in the database itself. So, you can do the query directly, without needing to store the command in…
-
2
votes2
answers406
viewsA: Select 2 latest records from Sql Server table
His column of timestamp can even be considered key, since it will most likely never be repeated. The consultation the way it is will always take the longest ((select max(TimeStamp) from myTable)),…
-
1
votes2
answers893
viewsA: Validate data in sql server
As it stands, if the date is not valid (considering your if validation), you are setting two values for the variable @vencimento ((select dateadd(day, -1, @data), DATEADD(month, 1, @data))). This is…
-
3
votes2
answers240
viewsA: How to count repeat emails in a Mysql table?
Create a sub-link to know which emails are repeating: SELECT COUNT(qtd) FROM (SELECT COUNT(*) AS qtd FROM cadastro GROUP BY email HAVING COUNT(*) > 1) as TB_TESTE test running…
-
1
votes2
answers211
viewsA: how can I get the last message from my`msg`field with`GROUP BY`
The most practical way I believe it to be using LIMIT: SELECT key_section, visualizado, msg, id_msg FROM chat ORDER BY id_msg desc LIMIT 1; Thus, only one line will be returned, ordered downwards by…
-
1
votes2
answers87
viewsA: Select only 24 records per day
You can use the LIMIT: SELECT date_format(hora,'%d/%m/%Y'), SUM(ponto) FROM pontos WHERE user = "teste" AND hora >= '2019-08-20' AND hora < NOW() LIMIT 24…
-
0
votes1
answer60
viewsA: ORA-01461 error when trying to save a CLOB text field generated by a template. What do I do to fix this?
The mistake "ORA-01461: can bind a LONG value only for Insert into a LONG column" refers to some restrictions that guy LONG has. As a suggestion, as per this answer in SOEN, you can: create the…
-
1
votes1
answer24
viewsA: Count quantities of a given attribute within a table
It’s just missing to tell the query who is the ch you want to reference: from carta_habilid ch inner join habilidades h on ch.idhabilidades=h.idhabilidades where ch.idcarta=c.idcarta group by…
-
0
votes3
answers1056
viewsA: How to convert an integer vector to an integer-only variable?
An alternative would be to turn this vector into a "string" and then pass it in one piece: char retorno_vetor[tam]; int retorno; int teste[] = {2, 3, 5, 6}; int tam = sizeof(vetor)/sizeof(int); for…
-
2
votes3
answers55
viewsA: Switch between results
For the explanation of the expected return, it would be more appropriate for you to use a right join instead of union, as it intends to bring primarily what has in the second table: SELECT DISTINCT…
-
1
votes1
answer81
viewsA: Struct receiving the same struct as attribute
The way you’re trying is not gonna make it because you’re trying to declare a structure where each knot will have 50 knots and each of these us will have other 50 knots and each of these us.. So I…
-
5
votes1
answer82
viewsA: Increasing list in c
It is possible to solve this issue with only one loop, although it requires more variables. Follows a possible solution: #include <stdio.h> #include <stdlib.h> int main() { int total =…
-
0
votes1
answer67
viewsA: Return of consultation in descending order
As I put in the comment, so that the question does not go unanswered, I will put the suggested here The mistake is '; before the where; the consultation shall be as follows:: $result_usuario =…
-
1
votes1
answer21
viewsA: Counting of similar objects in the vector
Whereas a sequence can also be formed by an element, you can use the following: int valorAtual = -1; int total = 0; for (int i=0 ; i<c.count() ; i++) { if (valorAtual != c[i]) total++; valorAtual…
-
1
votes1
answer111
viewsA: Limit characters and display points
Put the size validation on if; so, only enter if the href == teste and the size of strin is greater than 130: var u = i.link[E].type; if (i.link[E].href == "teste" && u.length > 130) { u…
-
0
votes2
answers102
viewsA: Relationship dates as a result of SQL query on Oracle
You can use the following: select CD_ATENDIMENTO, DT_ATENDIMENTO from ATENDIME where DT_ATENDIMENTO >= trunc(sysdate - interval '60' DAY) With this, you will bring the records with DT_ATENDIMENTO…
-
0
votes2
answers671
viewsQ: Display different message in case of timeout
I have an app web in PHP where I submit a set of invoices. This processing is done according to the due date. As some days take longer to finish than others, it may occur timeout. For being a legacy…
-
0
votes2
answers226
viewsA: Group by date in a timestamp field
Considering the idea of bringing the occurrences on the same date, ignoring the time, I believe that the query should stay like this: SELECT * FROM tbl_reclamacoes WHERE…
-
1
votes1
answer48
viewsA: Select by period
I believe that the most appropriate way to do this is by using the DATE_ADD(): SELECT 5125 matricula, CONCAT(fum.nomeguerra, ' / ' , fuc.nomeguerra) nomeguerra, date_format(es.data, '%d/%m/%Y') as…
-
0
votes4
answers288
viewsA: What’s this Join’s syntax error?
The mistake is that you grouped the join and then the on. The structure JOIN tabela ON campo_1 = campo_2 must at all times be maintained; that is, the "join together" a table, you must indicate the…
-
4
votes2
answers499
viewsA: Sql server skipping record id
Has an issue in SOEN that responds well to this problem, if using the SQL Server 2012 +: This is normal behavior since Microsoft added sequences from _SQL Server 2012, changing the way keys are…
-
13
votes1
answer1414
viewsA: Make mysql query with INNER JOIN between different mysql servers
You need to specify the full path table; if it is on another server, you must specify not only the server but also bank and schematic: [server].[database].[schema].[table] Getting something like…
-
0
votes1
answer39
viewsA: Trigger SQL Server
The error is that you are trying to update the tables sql-server use to control actions in bank, which is not allowed; these tables should be used for consultation only. To understand the logic: If…
-
0
votes4
answers177
viewsA: Count(*) returning null
Take off the having that is removing the return and puts the condition in itself select: SELECT DISTINCT CASE WHEN COUNT(*) = 4 THEN 0 ELSE COUNT(*) END FROM USER_IND_COLUMNS WHERE TABLE_NAME =…
-
0
votes1
answer135
viewsA: Conditional in Mysql clause
As you said in comment, missing a comma after the penultimate field of select. To make the consultation more dynamic, I changed the validation condition, checking if the id of subquery is the same…
-
3
votes4
answers2917
viewsA: Filter using only month and year on SQLSERVER
I believe the simplest way is to use the correct formatting of the kind date (here has a list of codes and formats usable for dates): SELECT NOME_CLIENTE, COUNT(NUMERO_BILHETE) AS 'QUANTIDADE DE…