Posts by Sorack • 27,430 points
864 posts
-
1
votes1
answer61
viewsA: Search set of records by date
What you need is to filter through the column data using the clause WHERE with NOT EXISTS: SELECT t.id, t.data, t.produto, t.qtd FROM tabela t WHERE NOT EXISTS(SELECT 1 FROM tabela t2 WHERE t2.data…
-
5
votes2
answers264
viewsA: What is the shortcut in Netbeans to close all "+" functions?
The standard is CTRL+SHIFT+-. But you can adjust in Tools -> Options -> Key mapping. Reference: Answer to the question Netbeans shortcut to minimise all functions? in the superuser…
-
0
votes2
answers1807
viewsA: INNER JOIN with equal fields in a table - Error: #1066 - Not Unique table/alias: 'tb_usuario'
The problem is that as you have two tables tb_usuario being related, you need to tell which one you refer to using an alias for the table SELECT comprador.nome as 'comprador', vendedor.nome as…
-
1
votes1
answer119
views -
1
votes1
answer918
viewsA: Mysql query - Take the next value greater than 0
If you ensure that there are no "holes" in your field id, then the solution below will show you the results you want: SELECT * FROM tabela t WHERE t.Velocidade > 0 AND (SELECT t2.Velocidade FROM…
-
1
votes2
answers368
viewsA: Customers who bought in one year but not another
You can use the clause NOT EXISTS to verify that there is a different billing than the year in question: SELECT tc.`cod-emitente` AS CODIGO, tc.`nome-emit` AS CLIENTE, fg.`ano` AS ANO FROM…
-
2
votes2
answers625
viewsA: Query SQL - CASE with LEFT JOIN
In this case the ideal would be to use a CROSS JOIN with subquery: SELECT alu.nome AS aluno, mat.nome AS materia, ISNULL((SELECT CAST(AVG(not.valor) AS VARCHAR) FROM nota not WHERE not.codigoMateria…
-
9
votes3
answers3355
viewsQ: What is the difference between LOCATE and INSTR functions?
The description of the function LOCATE, in free translation, it is: Returns the position of the first occurrence of substring. The description of the function INSTR, in free translation, it is:…
-
1
votes6
answers2251
viewsA: Remove all elements from an array that already exist in another
If you want to remove all elements contained in array a of array b, you can use the function filter: var c = a.filter(function(item) { return b.indexOf(item) === -1; // Não foi encontrado }); The…
-
4
votes2
answers151
viewsA: Count function - Mysql
Actually to add up the score you need the function SUM, and not the function COUNT. The result would be something like this: SELECT tim.time_nome, SUM(rod.rod_pontos) AS total FROM times tim INNER…
-
3
votes3
answers13782
viewsA: Changing the data type of an sql column
whereas the SGBD be it SQL Server you can change the type directly: ALTER TABLE [tabela] ALTER COLUMN [coluna] char(11);
-
7
votes3
answers799
viewsA: How to sort by the relevance of Like?
You can use the function LOCATE of MySQL within the ORDER BY: SET @termo := 'car'; SELECT * FROM tabela WHERE campo LIKE CONCAT('%', @termo, '%') ORDER BY LOCATE(@termo, campo); Explaining the query…
-
3
votes0
answers1140
viewsQ: What is the difference between Local Storage, Session Storage and Cookie?
What’s the difference between Local Storage, Session Storage and Cookie? What is the purpose of each of them and what differentiates them?
-
17
votes3
answers1699
viewsQ: Why doesn’t "= NULL" work?
In the SQL Server, by fetching all records with a given field with value NULL, if I do so no record is returned: SELECT * FROM clientes cli WHERE cli.cpf = NULL But if you use the following syntax:…
-
1
votes2
answers245
viewsA: Print more than one javascript copy
According to the documentation of window.print() no additional parameter for this function. Therefore, it is not possible to send more copies. A solution (which is not very cool) is you call 3 times…
javascriptanswered Sorack 27,430 -
0
votes1
answer35
viewsA: Addevent in the table
With the script import working properly below: <script type="text/javascript" src="https://addevent.com/libs/atc/1.6.1/atc.min.js" async defer></script> <table> <tbody>…
-
1
votes1
answer252
viewsA: Query mysql add day value to previous days
You can use a subquery to add up the quantity available in the previous days: SELECT vtd.*, (SELECT SUM(vtd2.total) FROM vw_total_diario vtd2 WHERE vtd2.pessoa = vtd.pessoa AND vtd2.data <=…
-
8
votes2
answers247
viewsA: Update two tables with condition
Although you haven’t specified the SGBD, to query to the SQL Server, for example, it would look like this: UPDATE dest SET dest.nome = ori.nome FROM destino dest INNER JOIN origem ori ON ori.cpf =…
-
6
votes1
answer2140
viewsQ: How to remove spaces leaving only one?
Considering a variable with a text in SQL Server. How can I remove 2 or more spaces within the text? In this case leaving only 1 space. For example: '1 tigre, 2 tigres, 3 tigres' It should result…
-
1
votes2
answers605
viewsQ: Trigger updates only to 1 record
Considering the following trigger: CREATE TRIGGER tgr_vendas_d ON vendas FOR DELETE AS BEGIN DECLARE @valor DECIMAL(10,2), @data DATETIME; SELECT @data = d.data, @valor = d.valor FROM deleted d…
-
2
votes2
answers1472
viewsA: Trigger that updates record in a table
Instead of using insert, use the update: UPDATE bk_transportadora SET nome = new.nome WHERE id = new.id; Now a relevant information that is not an answer to your question: Maybe the best way to…
-
10
votes1
answer4174
viewsA: How to concatenate lines?
One way (prior to SQL 2012) is to use a variable to concatenate the row results as follows: DECLARE @texto varchar(max); SELECT @texto = ISNULL(@texto + ', ', '') + cli.nome FROM cliente cli; print…
-
7
votes1
answer4174
viewsQ: How to concatenate lines?
How to concatenate all the results of a query in SQL Server in order to return all information in one variable? For example, considering a table cliente with the following composition:…
-
1
votes1
answer726
viewsA: How to pass parameters and catch them with angular $state.go?
To get the value you must use the service $stateParams which will contain the value that was passed by $state.go. For example, in the menuProfissionalCtrl: ... console.log($stateParams.nome); ...…
-
6
votes1
answer26028
viewsA: Compare NULL using CASE SQL
To compare a null value you must use it in WHEN with IS NULL: SELECT COUNT(i.is_active) AS NUMERO_PROJETOS, CASE WHEN f.br_nome_ger_executo IS NULL THEN 'Gerencia nao informada' ELSE…
-
5
votes1
answer11299
viewsA: Cluster and Sum in Oracle
You can use the clause GROUP_BY together with the function SUM: SELECT cli.grupo, SUM(com.valor_compra) AS total_gasto FROM clientes cli INNER JOIN compras com ON com.id_cliente = cli.id GROUP BY…
-
0
votes3
answers2405
viewsA: Export query output as Insert scripts
You can use the procedure down below: if object_id('ferramenta.gerar_insercao', 'P') is null begin exec('create procedure ferramenta.gerar_insercao as'); end; go alter procedure…
sql-serveranswered Sorack 27,430 -
0
votes2
answers283
viewsA: Play Audioclip with . wav in another JAVA package
If you are in the resource folder you can use the getResourceAsStream: ... AudioClip c = Applet.newAudioClip(Principal.class.getResource("/recurso/audio.wav").toURI().toURL()); c.play(); ...…
-
3
votes1
answer564
viewsA: preApproval data is required
According to the documentation Transparent Recurring Payment you must use the following headers: Content-Type application/json;charset=ISO-8859-1 to send data in format JSON. The way you’re…
-
1
votes2
answers1828
viewsA: Learning to use ENUM in Java
First I’ll use another name for enum, considering the convection of code, which classes should start with capital letters and _ should be avoided. There are several ways to make the comparison you…
-
1
votes1
answer4757
viewsA: Checkbox in Angular
Your code has several problems: The field reference in your HTML is as categoria_cnh.value1 when these attributes would belong to the driver, then the correct one would be…
-
2
votes1
answer34
viewsA: Problem in the installation of Angularjs
The only file required is the angular.js or the angular.min.js. If you are using the CDN file will look like this: <script type="text/javascript"…
-
6
votes3
answers1408
viewsA: What are the differences between the forms of dependency injection?
Form 1 (Implicit Annotation): It is the simplest way to handle dependencies and assumes that the signatures of the function parameters are dependency names. In the example above dependencia is a…
-
1
votes2
answers2319
viewsA: How to use like in a comparison of fields in different tables?
In that case a JOIN is more interesting than a subquery. Follow the example for the case 2: SELECT sum(sd3_sub1.D3_QUANT) AS producao FROM SD3010 AS sd3 WITH(NOLOCK) INNER JOIN SD3010 AS sd3_sub1…
-
3
votes1
answer573
viewsA: Column Junction: HTML5 and Angular
The feature of joining lines in the HTML is the rowspan. HTML rowspan Attribute Original: The rowspan attribute specifies the number of Rows a Cell should span. Free translation: The rowspan…
-
10
votes5
answers15150
viewsA: How to avoid "Cannot read Property ... of Undefined" error?
I ended up using the information of the 3 responses proposed so far. Reading the answer from @Linq I saw that the name of the resource is null Propagation and that, although it does not exist in…
-
10
votes5
answers15150
viewsQ: How to avoid "Cannot read Property ... of Undefined" error?
Considering the following code: var a = {}; if (a.b.c !== undefined) { console.log("definido!"); } else { console.log("indefinido!"); } Is there any way to check each property without having to test…
-
4
votes2
answers172
viewsA: Is it possible to copy directory names without copying their contents?
By changing your method you can do as follows: private static List<File> filtrarDiretorios(File origem) throws IOException { List<File> diretorios = new ArrayList<>();…
-
1
votes2
answers543
viewsA: Pick up data using Join in two table 1 for many
You can add a GROUP_CONCAT at your query: $this->db->select('produtos.*, GROUP_CONCAT(grupo_preco_produtos.grupo_preco_venda SEPARATOR ",") as grupo_preco_venda');…
-
1
votes2
answers6454
viewsA: How to use Sum with subquery
The problem is in using the subquery within a SUM. You can get around this problem by changing your subquery for a JOIN: select sum(convert(decimal(5, 2), x.quantidade)) as presenca from sra010 as…
-
11
votes3
answers10837
viewsA: Replace is not a Function
The function replace is a function of the type String. The variable QuantoFalta is the product of a mathematical operation, so it is not a String. Utilize toString to transform it: ... ...…
-
0
votes2
answers1510
viewsA: "No 'Access-Control-Allow-Origin' header is present" cakephp
In the endpoint of your service add: $this->response->header('Access-Control-Allow-Origin', '*');
-
16
votes3
answers1408
viewsQ: What are the differences between the forms of dependency injection?
Considering the injection of dependencies into Angularjs, there are some ways to do it. The modes as far as I know are: Form 1: angular .module('meuModulo', []) .controller('MeuController',…
-
1
votes1
answer305
viewsA: $Location.path of Angular changed?
Your first line with the declaration of controller is incomplete. The correct would be: ... .controller('loginCtrl', ['$scope', '$stateParams', '$http', '$location', function ($scope, $stateParams,…
-
0
votes3
answers2481
viewsA: Find a component by name
You can use the function System.Classes.TComponent.FindComponent: TEdit(FindComponent(vMinhastring)).Text := 'Meu texto'; Findcomponent Original: Findcomponent Returns the Component in the…
-
7
votes1
answer843
viewsA: Delphi picking value from the field created at runtime
From what you explained, you don’t have multiple components with the same name, but you are using the same variable to create these components. One way you don’t have to worry about it, instead you…
-
2
votes1
answer664
viewsA: Query to separate records
For the first part, as you said yourself, you want to group and count events by phone and date. For this we will use the clause GROUP BY and the function COUNT. GROUP BY Original: GROUP BY will…
-
1
votes2
answers919
viewsA: Read string and call in java voice
You can use the service of IBM Bluemix - Watson/Text to Speech. The first million monthly character is free and after that it costs $0.02 per thousand characters. There is a voice referring to…
-
0
votes2
answers98
viewsA: Repeat condition in WHERE at the time of query
One solution is to count the records of subquery in response to his another question as follows: SELECT prod.ID, prod.NOME FROM PRODUTOS prod WHERE (SELECT COUNT(rel.ID_CARAC) FROM RELACAO rel WHERE…
-
11
votes3
answers17188
viewsA: Apply CSS when two classes are together
The original code is almost right. What makes the difference is that when you have a space in the style setting of CSS (.nome1 .nome2) is defining that the style will be applied to the class nome1…