Posts by Sorack • 27,430 points
864 posts
-
0
votes1
answer532
viewsA: Separate values from a multi select in columns
Your table seems to be modeled in a way too complicated for the desired purpose. I believe that a way out would be to have an intermediate table to store the registration codes. Despite this you can…
-
1
votes2
answers587
viewsA: Sort by the result of the sum of two SUM - MYSQL
You can reach the desired end using a suquery and referencing the position of the column in the ORDER BY: SELECT x.atendimento_duracao + x.texto_duracao + chat_duracao AS total_duracao FROM (SELECT…
-
1
votes2
answers96
viewsA: Save a page from an Htmlpage (java)
Simplest way to save a file using Java 8 is as follows: Files.write(Paths.get(PATH + "paginaIndex.html"), paginaIndex.asXml().toString().getBytes(Charset.forName("ISO-8859-1")));…
-
2
votes2
answers680
viewsA: How to make a button appear/disappear only from one of the loops created by ng-repeat? (Programming in Angularjs)
You must work with two lists, one for the cart and one for the products. Use a service to pass the information to the cart list, thus allowing only one instance of the cart to exist for your…
-
0
votes1
answer158
viewsA: How to Make two or more Select categorized in the same query
If you want to bring them all in one query fixed can do as in the example: SELECT COUNT(CASE WHEN left(w.wd, 1) = 'a' THEN 1 END) AS a, COUNT(CASE WHEN left(w.wd, 1) = 'b' THEN 1 END) AS b,…
-
4
votes1
answer50
viewsA: Why does variable increment function not work in Angularjs? Am I not accessing the variable correctly?
Are you trying to access a position of array by the name of the variable in which the values are set. To access an item of array you must use the position, or change to a Object:…
-
0
votes1
answer43
viewsA: Select values from another table with more than one row in Websql
You must work with promises asynchronously as follows: databaseValues.setup(); databaseValues.bancoDeDados.transaction(function(transacao) { transacao.executeSql('select * from parceiros', [],…
-
1
votes1
answer3146
viewsA: Turn rows into a select column - PIVOT - SQL Server
Note that the grouping you want to do is done by 3 columns: the column conjunto, pai and filho. In the case of PIVOT results are grouped by the columns that will be selected in a subquery EXCEPT by…
-
2
votes1
answer2407
viewsA: Direct PDF Printing on Java Printer
An option to work with PDF is to use the library Apache PDFBox that will extract the contents of your file and allow it to be printed: public static void main(String args[]) throws Exception {…
-
1
votes2
answers614
viewsA: Toggle the colors of a column using the java library - apache poi
A very simple way is to create a method for this: private static void estilizarCor(CellStyle estilo, Integer indiceColuna) { IndexedColors[] cores = new IndexedColors[]{ IndexedColors.AQUA,…
-
2
votes2
answers81
viewsA: Search all records that exist in another table at least once
Doing directly in the query would look like this: SELECT * FROM orcamentos_principais op WHERE op.status = 'ativo' AND EXISTS(SELECT 1 FROM orcamentos_novo on INNER JOIN usuarios_categorias uc ON…
-
2
votes1
answer926
views -
0
votes1
answer1021
viewsA: Consultation with MAX(DATE)
Simplify your query. Utilize NOT EXISTS to check if it is the last date: SELECT uc.usurazaosocial AS razao_social, uc.usunome AS nome_fantasia, t.tarid AS tarefa, CONVERT(date, a.ativdata, 103) AS…
-
4
votes3
answers2851
viewsA: Java repeated letter counter
You can use the Collections of Java in your favor as follows: public static void main(String[] args) { Map<String, Integer> ocorrencias; ocorrencias = contar("Vê se tira notas boas!");…
-
0
votes1
answer1178
viewsA: Working day function
Whereas you have a holiday chart: IF OBJECT_ID('calcular_dias_uteis', 'FN') IS NULL BEGIN EXEC('CREATE FUNCTION calcular_dias_uteis() RETURNS INT AS BEGIN RETURN 1 END'); END; GO ALTER FUNCTION…
-
2
votes2
answers136
viewsA: Null Result Coming in query
You just need to add the ELSE in his CASE: SELECT title, SUM(count) AS count FROM (SELECT CASE WHEN estadoid = estadoidautor AND estadoid = meddoc1 AND estadoid = meddoc2 AND estadoid = meddoc3 THEN…
-
4
votes3
answers536
viewsA: Instanceof with List in JAVA
You can check for the item instead of the list: public static void insertLog(List list) { for (Object item : list) { if (item instanceof Transaction) { insertLog((Transaction) item); } else if (item…
-
1
votes2
answers313
viewsA: Use INSERT using SELECT (Node.js and Mysql)
The character you are using is not a delimiter of String valid for the JavaScript. I made some modifications to query also to represent it more easily: var query = "INSERT INTO uso(id_usuario,…
-
0
votes1
answer99
viewsA: Filter list from similar strings
The filter accepts a third parameter that basically forces the value to be exact: ... <tr ng-repeat="post in posts | filter:{classification:classes}:true"> ... You can check the documentation…
-
1
votes1
answer153
viewsA: How to make a pie chart clickable
You just need to add the event pie -> dispatch -> elementClick in the chart options: pie: { dispatch: { elementClick: function(evento){ console.log(evento) } } } angular .module('meuApp',…
-
5
votes1
answer31
viewsA: How do I check if a user has a confirmed email with only one query?
You can link the two tables with the clause JOIN. Using INNER JOIN you will only result if there are records in the two tables. SELECT * FROM tbl_usuario tu INNER JOIN tbl_valida_email tve ON…
-
3
votes1
answer1312
viewsA: See The Employee Salary Amount on a Given Date
Its whole problem is because the tables seem to be modeled in a way too complicated for the problem that must be solved. I suggest that, if possible, a table be created salario that has the value,…
-
0
votes1
answer65
viewsA: Combination of javascript function
You can request with two parameters: function _search(organ_id, letter) { var params = {}; params.organ_id = organ_id; params.letter = letter; return $http.get('/api/services.json', {params:…
-
0
votes2
answers461
views -
2
votes1
answer1533
views -
0
votes2
answers1495
viewsA: SQL Server Function - Holidays
Your holiday function is not very cool for a number of reasons, but I will focus on your primary function. First I will change the name by removing the nao that can cause confusion. ALTER FUNCTION…
-
0
votes1
answer1018
viewsA: Error converting from varchar to smalldatetime
I suggest you simplify your function: ALTER FUNCTION dbo.fn_calc_horas_uteis(@inicio datetime, @fim datetime) RETURNS NUMERIC(15, 2) AS BEGIN DECLARE @minutos INT; DECLARE @horarios TABLE(entrada…
-
4
votes2
answers112
viewsA: Lock of characters with exception e-mail field
You just need to add them inside the brackets: var regex = new RegExp('[^ 0-9a-zA-Zàèìòùáéíóúâêîôûãõ\b-@_]', 'g');
javascriptanswered Sorack 27,430 -
3
votes1
answer610
viewsA: Drop Inventory with SQL Triggers
In most cases the ideal is not to store calculation attributes in the tables, but if you want to make a TRIGGER for this, would be as follows: IF OBJECT_ID('tgr_itemvenda_ai', 'TR') IS NULL BEGIN…
-
3
votes2
answers1980
viewsA: Generate Inserts from a populated table
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…
-
1
votes2
answers1009
viewsA: Repeat previous rows when there is no record in SQL SERVER data
Use a subquery matching ORDER BY by the date you wish and TOP: DECLARE @datainicial DATE = '20170201'; DECLARE @datafinal DATE = '20170205'; WITH cte AS (SELECT @datainicial AS data_guia UNION ALL…
-
1
votes1
answer710
viewsA: Doubt Exercicio Collections - Queue Interface
Although you don’t understand why two rows, the implementation would be something like this: Class Aviao: public class Aviao { private String nome; private int codigo; public Aviao(String nome, int…
-
1
votes1
answer824
viewsA: How to return 2 objects at the same time in a Java method?
You can return some data structure that satisfies your problem: public class Equacao2Grau { int a, b, c; public int CalculoDelta() { return (int) (Math.pow(b, 2) - 4 * a * c); } public…
-
2
votes2
answers3313
viewsA: I need to list the amount of an 'X' product that each customer bought
What you want can be achieved by summing the grouping according to the customer: SELECT cli.Nome AS cliente, prod.Descricao AS produto, SUM(co.QuantItem) AS quantidade FROM cliente cli INNER JOIN…
-
1
votes2
answers897
viewsA: Regex to separate a string
You can use the following regular expression: /([0-9]{2}\/[0-9]{2}\/[0-9]{4}) a ([0-9]{2}\/[0-9]{2}\/[0-9]{4})/g This expression will look for 2 numbers, followed by a bar, followed by 2 more…
javascriptanswered Sorack 27,430 -
2
votes1
answer3158
viewsA: How to do Cifra de cesar
You should consider that the indexes start at 0 and not at 1. So, if the desired shift key is 5, the number used to shift the character should be 4. Change the following line of the method…
-
2
votes1
answer124
viewsA: Dump Database
Make a SELECT on the table backupset: SELECT b.database_name AS base, CASE b.type WHEN 'D' THEN 'Completo' WHEN 'L' THEN 'Log' WHEN 'I' THEN 'Diferencial' ELSE 'Outro' END tipo, CONVERT(VARCHAR,…
-
3
votes2
answers818
viewsA: How to count the number of occurrences of a String in a Jsonarray?
You are doing many unnecessary operations on your code. I rewrote the method to perform the count as follows: private static Map<String, Integer> contar(JSONArray array) { List<String>…
-
1
votes2
answers64
viewsA: Database, display name via ID
SELECT evt.data, venc.nome AS vencedor, perd.nome AS perdedor FROM placares p INNER JOIN eventos evt ON evt.id = p.evento_id INNER JOIN jogadores venc ON venc.id = p.vencedor_id INNER JOIN jogadores…
-
1
votes2
answers1906
viewsA: Calculate Difference between 2 dates (has time in them)
You can use a function to format the time automatically: IF OBJECT_ID('dbo.formatar_tempo', 'FN') IS NULL BEGIN EXEC('CREATE FUNCTION dbo.formatar_tempo() RETURNS INT AS BEGIN RETURN 1 END'); END;…
-
3
votes2
answers3257
viewsA: How to remove a part of a string?
You can use a regular expression to extract the values from your String: ([^,\:]+)\:([^\,]+) This regular expression will look for any sequence of 1 or more characters that are not , nor :…
-
1
votes1
answer515
viewsA: Problem with ng-checked Angularjs!
Your problem is somewhat confused, but follows an example using a function _ inicializar which allows the selection and filtering to be performed immediately upon starting the controller: angular…
-
1
votes2
answers242
viewsA: Httpget parameter not detected
To pass parameters on query of $http#get you must pass the object config as the second parameter: var params = {}; params.id = id; $http.get('http://localhost:61223/usuario/carregarUsuarioPorId',…
-
0
votes1
answer318
viewsA: How to update a table by going through another table in Mysql?
Your modeling is a bit confusing, but if you want to make a UPDATE based on another table, just use the clause FROM as an alias and JOIN, together with the GROUP BY by product code and SUM to…
-
4
votes1
answer844
viewsA: How to define the order in which components will receive focus through TAB?
Use the class FocusTraversalPolicy to define the order of focus of the components of a container. To do so, extend the class FocusTraversalPolicy, implement the policy of focus and attribute using…
-
1
votes2
answers990
views -
3
votes1
answer33
viewsA: I need help with replaceAll for monetary values!
The replaceAll returns a String and does not change the current one. You need to do the following for your code to work: String sal = "1500,32"; double salario = 0; sal = sal.replaceAll(",", ".");…
-
2
votes1
answer87
viewsA: Hide ng-repeat item after 5 seconds
You can use the service $timeout together with the ng-class to set a class after 5000 milliseconds (5 seconds) which will make the item disappear by assigning the class escondido in the following…
-
1
votes2
answers329
viewsA: Group table data with INNER JOIN
If you do not want to change the way the display code is implemented you can change the query to the following: SELECT x.tipo, x.id_pergunta, x.id_opcao, x.descricao FROM (SELECT 0 AS tipo,…
-
1
votes3
answers1195
viewsA: Convert nvarchar(50) field to SQLSRV table datetime
Create a new column with the new type, update it with the converted values, delete the old column, create again as DATETIME, update it with the values of the new column and delete this auxiliary…