Posts by Sorack • 27,430 points
864 posts
-
1
votes1
answer68
views -
1
votes1
answer1101
viewsA: Connection being refused
As described in your question (by the error returned) your server is trying to connect to the database on localhost, check if the object with the connection settings is with the correct information…
-
1
votes2
answers88
viewsA: Query in SQL SERVER 2017
You only need to use the clause EXISTS together with NOT in the WHERE to determine that it wants only the interaction that it does not have or with longer date: SELECT c.cha_codigo [Codigo do…
-
0
votes1
answer522
viewsA: Problem using parameter in Preparedstatement
You cannot pass the column name to a PreparedStatement. One solution to work around your problem is to check which column was selected on WHERE of query: SELECT id_evento, nome_cliente, numero,…
-
1
votes1
answer183
viewsQ: Unit Test - How to verify an expected error?
In a unit test for a module using Mocha and Chai need to check if an error is returned if the parameter format is invalid. The function of the module in question returns a Promise. The example below…
-
0
votes2
answers415
viewsA: Calling functions in ngClass
You can mix the attribute class (with fixed classes) with the ng-class for function return: <input type="text" class="text padd" ng-class="styleClass(5)" ng-model="firstName">…
-
4
votes3
answers5107
viewsA: Working days and Java 8 API, how to check?
You can use the Google Calendar API as proposed by the documentation: import com.google.api.client.auth.oauth2.Credential; import…
-
2
votes1
answer410
views -
1
votes1
answer471
viewsA: Problems connecting Node.JS Express in Mysql
According to the answer to the question Mysql 8.0 - Client does not support Authentication Protocol requested by server; consider upgrading Mysql client: Perform the following query in the MySQL…
-
2
votes4
answers593
viewsA: Sql - Query of two maximum values
You just need to check the records you don’t have data or valor greater with the NOT EXISTS: SELECT m.* FROM minha_tabela m WHERE NOT EXISTS(SELECT 1 FROM minha_tabela m2 WHERE m2.codigo = m.codigo…
-
6
votes1
answer10860
viewsA: How to use async / await in get request using Vue+Axios?
If you want to apply the async in the code of mounted you can do it as follows: ... async mounted() { try { let response = await axios.get('http://localhost:8080/wp-json/api/v1/skills'); this.skills…
-
1
votes2
answers2968
viewsA: Store Promise output in a variable
You can use the instruction await to await the return of the function: ... // Funções assíncronas let marcas = await consultaMarcas(); console.log(marcas); ... Adding to the most complete example…
-
2
votes2
answers49
views -
1
votes1
answer61
viewsA: I’m having trouble reading a service variable on other controllers
Use the $rootScope to store a global variable is not a good practice because its variable will be available everywhere in the application without due treatment. You started with the right idea of…
-
0
votes2
answers716
viewsA: What do the three dots mean ... before Document.querySelectorAll
This is a syntax of ES6 calling for operador spread. Operador Spread The spread operator allows an expression to be expanded to places where multiple arguments (by function calls) or multiple…
javascriptanswered Sorack 27,430 -
0
votes1
answer84
viewsA: Sql Procedimento
You can use a procedure as shown below: CREATE PROCEDURE reservar(@id_quarto INT, @data_entrada DATE, @data_saida DATE) AS BEGIN DECLARE @dias TABLE(dia DATE); -- Gera um registro para cada dia…
-
0
votes1
answer107
viewsA: Interaction in browser behavior when leaving the page
You can use the function onbeforeunload of provider $window: ... $window.onbeforeunload = function() { return 'mensagem!'; } ...…
-
2
votes3
answers1447
viewsA: Help select to bring field even if null
You need to make use of the LEFT JOIN instead of INNER JOIN, even if there are no records in the table the result will be listed. It will also be necessary to reorganize your query so that the table…
-
4
votes2
answers225
viewsA: How to group a list in javascript and calculate subtotals?
You can iterate the array to obtain the expected result: function somar(antigo) { var resultado = []; antigo.reduce(function(novo, item) { if (!novo[item.nome]) { novo[item.nome] = { valor: 0, nome:…
javascriptanswered Sorack 27,430 -
1
votes1
answer340
viewsA: How to define multiple variables at once within a Trigger in Sqlserver
DECLARE @id BIT, @nome NVARCHAR(100), @telefone NVARCHAR(30), @email NVARCHAR(100); SELECT @id = id, @nome = nome, @telefone = telefone, @email = email FROM inserted…
sql-serveranswered Sorack 27,430 -
0
votes1
answer116
viewsA: Display a record by quantity and the most repeated value of a column
My suggestion is that you create a VIEW totalling the amount based on locality and disease: CREATE VIEW vw_grafico AS SELECT localidade, tipo_doenca, COUNT(localidade) AS quantidade FROM tb_grafico…
-
2
votes1
answer153
viewsA: Count/Dense_rank sql grouped
If you are using SQL Server as your question indicates, probably the function you want to use is the ROW_NUMBER and not DENSE_RANK: SELECT CICLO, CODFIL, CODITPROD, ROW_NUMBER() OVER (PARTITION BY…
-
1
votes2
answers85
viewsA: Add rows with the same ID in additional columns
You don’t need one pivot. You can link the table with JOIN: WITH resultado AS ( -- Aqui vai sua query atual ) SELECT r1.*, r2.*, r3.* FROM resultado r1 LEFT JOIN resultado r2 ON r2.id = r1.id AND…
-
1
votes2
answers6988
viewsA: Query with SELECT and SUB SELECT in Mysql
Use the clause EXISTS together with the NOT to select only the message with the longest date: SELECT cli.id, cli.nome, cli.senha, cli.email, cli.cpf, cli.celular, cli.data_nasc, cli.genero,…
-
2
votes4
answers327
viewsA: Return results for all months of the interval
You can create a table of months, since it would make your life easier: CREATE TABLE mes ( id INT, mes VARCHAR(10) ); INSERT INTO mes VALUES(1, 'JANEIRO'), (2, 'FEVEREIRO'), (3, 'MARÇO'), (4,…
-
0
votes1
answer152
viewsA: Table Fipe Change year 3200
You can solve this by changing the code 3200 for Zero KM in the presentation layer: SELECT id_ano, CASE ano WHEN 3200 THEN 'Zero KM' ELSE ano END AS ano FROM fp_ano WHERE codigo_modelo = '$ano'…
-
3
votes1
answer65
viewsA: convert 1 to active and 0 inactive within ng-repeat angular
One option is to use a ternary operator: <tbody ng-repeat="oper in operadorasCartoes" > <tr> <td>{{oper.nome}}</td> <td>{{oper.cnpj}}</td>…
-
1
votes2
answers428
viewsA: Cursor problem: SQL Server
You can create a variable table and insert the records into it. After this create, outside the ifs the cursor desiring: DECLARE @banco TABLE(banco VARCHAR(10), tipo VARCHAR(10)); IF @opcao = '1'…
-
1
votes1
answer64
viewsA: Help! How this select works
FROM STATION selects data from the table STATION; LOWER(CITY) will compare the column CITY with the lowercase letter; REGEXP_LIKE(..., '^[aeiou]') compare start with vowels; DISTINCT does not…
-
1
votes1
answer5598
viewsA: Multiply two columns in a select
Basically it is only necessary to perform a SUM upon their multiplication of the columns: SELECT SUM((Valor_Unit * Quantidade)) AS total FROM tabela
-
1
votes1
answer298
viewsA: How to return the sequence of the week in the reported period?
Add the field sequencia_semana as follows: SELECT YEAR(dadf331.datlan) AS ano, MONTHNAME(dadf331.datlan) AS mes, WEEK(dadf331.datlan) AS semana, SUM(totped) AS totalv, (WEEK(dadf331.datlan) + 1) -…
-
0
votes1
answer161
viewsA: How to filter dates through Angularjs?
You can create a custom filter for your dates as follows: (function() { angular .module('meuApp', []); angular .module('meuApp') .filter('entre', entre); function entre() { return function(itens,…
-
0
votes3
answers1569
viewsA: Form completion with return of a json
If you will use AngularJS, use it in its entirety. Avoid mixing. The call with jsonp can be checked as below: (function() { angular .module('appCep', []) .controller('CepController', CepController);…
-
3
votes1
answer1113
viewsA: How to Insert into the table if the record does not exist
You can use a SELECT instead of VALUES in the INSERT: INSERT INTO turma_materia(ID, turma, materia) SELECT 1, 1, 1 WHERE NOT EXISTS (SELECT 1 FROM turma_materia WHERE ID = 1 AND turma = 1 AND…
-
0
votes1
answer30
viewsA: Query to catch a student’s mistakes and successes
To get the desired result you can create a query grouped by matricula_aluno and use the function COUNT together with a CASE testing the spine acertou: SELECT r.matricula_aluno, COUNT(CASE WHEN…
-
3
votes1
answer43
viewsA: Postgresql: Catch amount of errors and hits
Something like that: SELECT t.acertou, COUNT(1) FROM tabela t GROUP BY t.acertou If you wanted to show as just a record, you can use subquery: SELECT (SELECT COUNT(1) FROM tabela t WHERE t.acertou)…
-
0
votes3
answers122
views -
0
votes1
answer49
viewsA: Doubt - Query SQL Server condition
One way to achieve the result you expect is to use the query above within a subquery in the FROM and apply the filter after this. Replacing would look more or less like this: SELECT * FROM (SELECT…
-
1
votes1
answer133
views -
4
votes2
answers460
viewsA: Hide Div Jquery
You can use the selector contains: $("div.texto:contains('carro')").hide(); $(document).ready(function() { $(".acionador").click(function() { $("div.texto:contains('carro')").hide(); }); });…
-
1
votes1
answer106
viewsA: Data Manipulation
You can use the function DATEADD as follows: SELECT CONVERT(VARCHAR(8), DATEADD(HOUR, 8, ''), 114); The above example will result in 08:00:00. Applying in your query: CONVERT(VARCHAR(8),…
-
1
votes3
answers239
viewsA: Error searching for field value - Javascript
At the moment the code is executed the element is not yet in the DOM. Change the start of your script for: function myfunction(){ var fruta = document.getElementById("nome").value; ... And the end…
-
3
votes2
answers229
viewsA: SQL Maximum value of another table
In your case you can use a subquery to obtain the desired result: SELECT v.*, (SELECT MAX(lt.MaximumKM) FROM Leases l INNER JOIN LeaseTerms lt ON lt.TermID = l.TermID WHERE l.VehicleID =…
-
1
votes2
answers788
viewsA: Problem with CASE WHEN SQL-SERVER
You can convert the numeric to VARCHAR since all the results of CASE must have the same type: SELECT CASE WHEN VALOR > 0 THEN CAST(VALOR AS VARCHAR) ELSE 'Não tem' END AS NOMECOLUNA FROM…
-
2
votes1
answer1902
viewsA: how to add different record values?
SELECT SUM(x.valor) AS total FROM ( SELECT valor FROM teste3 WHERE id = 1 UNION ALL SELECT valor2 FROM teste3 WHERE id = 2 ) x;
-
1
votes1
answer116
viewsA: How to total the number of records per Category using a VIEW SQL SERVER
SELECT cmp.categoria, COUNT(1) AS quantidade FROM VMostraProfessor cmp GROUP BY cmp.categoria
-
3
votes3
answers86
viewsA: Problems with SELECT RIGHT JOIN
How you want to separate for table reasons B and then restrict by the table A, I suggest you make a subselect as follows: SELECT b.TodosOsMotivos, (SELECT COUNT(1) FROM A a WHERE…
-
2
votes2
answers432
viewsA: Permutations of an integer disregarding the zeros on the left
I was able to arrive at a calculated result the proportion in which the number zero appears and discounting from the permutation calculation. The end result was as follows: import java.util.HashMap;…
-
0
votes1
answer574
viewsA: Help with scrambled words
You can use the following implementation: import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.ExecutionException; import…
-
0
votes1
answer213
viewsA: Sum values in a Mysql Count
You probably have some lines with the value NULL in the column size. Utilize COALESCE to consider these values as 0: ... SUM(COALESCE(Size, 0)) AS TotalDeUp ...…