Posts by bruno • 7,237 points
193 posts
-
0
votes2
answers104
viewsA: Data string-to-date Procedure
I assume that the first day of the week is Sunday, meaning that if you pass as a parameter a date whose corresponding day of the week is Sunday, the stored Procedure will return the next day…
-
23
votes4
answers850
viewsA: Return all equal items from different groups
I think the following solution returns the result you want. This query returns all groups that have exactly the same elements as group 1. SELECT T.GRUPO FROM TESTE T LEFT JOIN ( SELECT DISTINCT…
-
3
votes1
answer782
viewsA: Order by SQL Server under Procedure
You do not need to create a subquery. SQL Server allows you to include in GROUP BY columns that do not appear in the SELECT statement. Just add the id column in GROUP BY and sort it using the new…
-
3
votes4
answers7937
viewsA: How can I increment a day to a Java date?
I suggest using the class Calendar Date dataTeste = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(dataTeste ); cal.add(Calendar.DATE, 1); dataTeste = cal.getTime();…
-
1
votes1
answer3043
viewsA: mysql error code 1111. invalid use of group Function
Each SELECT statement can only have one GROUP BY statement. Implicitly your query needs two instructions from GROUP BY: the first to count delayed flights, the second to give the maximum of the…
-
0
votes1
answer118
viewsA: Query with two summations for the same column
Yes, it is possible to do this without resorting to a subquery. Since "Sales Settled" is a subset of "Sales Total" you should use the first query as the basis for what you want. Uses a CASE to…
-
5
votes3
answers1152
viewsA: How to make an object array have only unique values?
Try it like this: $unicos = array_unique($colecao, SORT_REGULAR); The function array_unique() takes as arguments two parameters (the second parameter is optional): array array_unique ( array $array…
-
1
votes1
answer609
viewsA: Is there a parameter passage in a Rigger?
Your attempt was very close to achieving the goal. Try it this way: DELIMITER $$ CREATE TRIGGER atualizarStatus AFTER UPDATE ON sessao FOR EACH ROW BEGIN IF NEW.vagas = 0 THEN UPDATE atividade SET…
-
4
votes2
answers193
viewsA: Insert in Mysql does not run
Your mistake is because match be a reserved word. This means that in order to be used as an identifier (column or table name, for example) it needs a special treatment. From your comment I saw that…
-
1
votes1
answer79
viewsA: Explicit conversion with "static_cast" does not occur
This happens because the operator / when applied to two integers produces as a result an integer. For the operation to return one float you must cast one of the arguments to float. For example:…
-
1
votes1
answer156
viewsA: QT: How to prevent changing the content of a Qtablewidget
It’s very simple, and as you say in the question the solution is to use flags. To deactivate the editing mode just do: QTableWidgetItem *item = new QTableWidgetItem();…
-
2
votes1
answer2043
viewsA: How to set the location of Jbutton according to the size of a Panel
The main question should be: Why do you want to position your components absolutely? Java interfaces have the possibility to run on a wide number of platforms, with different screen resolutions and…
-
1
votes1
answer1226
viewsA: setPreferredSize and setSize do not work
By default, Jframe uses Borderlayout, which means that when you add a Jbutton, as this is the only component in the frame, it will be resized to fill the entire window. You can consult this example…
-
4
votes1
answer1219
viewsA: Increase PHP/Mysql script performance
Since you do not perform any file data processing, I see no need to process the file sequentially. So, in my opinion, you can remove the loop (loop) and process the file at once with the LOAD DATA…
-
1
votes1
answer38
viewsA: QT disable Qpushbutton
Yes, it’s possible. And it’s easier than it might seem in the beginning. You can use the function Sender() void processEvent() { QPushButton *button_ = qobject_cast<QPushButton *>(sender());…
-
0
votes1
answer164
viewsA: Compare varchar in Procedure
The problem is in your stored database and it is due to the fact that the parameter has the same name as the table column. You need to qualify the column name. For example like this: # Procedure…
-
3
votes1
answer42
viewsA: Structuring in the bank the paths to the images and videos of my product?
I would create two tables to store this information. Because it may be possible for a photo to apply to more than one product. In case that never happens you can simplify the model, but I would do…
-
1
votes1
answer268
viewsA: Deletion with MYSQL reference integrity
As indicated in the comments you do not need to do this management manually. If your goal is to delete the logs from all tables you can use the option ON DELETE CASCADE. Here’s a short example using…
-
2
votes1
answer271
views -
3
votes1
answer79
viewsA: Undefined Reference to Symbol when compiling program in C++
Include the library curlPP is not enough, you have to compile your program using also the library Curl. Try it this way: g++ -lcurlpp -lcurl -o http_get httpreq.cpp…
-
3
votes1
answer2088
viewsA: How to convert int to Qstring?
One of the most positive aspects of this framework is its extensive documentation. Even today, I always have the API open to clarify the simplest questions. I highly recommend your reading to those…
-
3
votes1
answer734
viewsA: Error "illegal start of Expression"
The error lies in your method stats public void stats (int num) { int i; float total=0, perc; for (i=0;i<num;i++) { total = total +…
-
2
votes1
answer379
viewsA: Help - Collation Conflict
You say the two databases (databases) have the collation, most likely then is that the columns you are using in your query, have a collation different from the default database. In any case you can…
-
2
votes1
answer653
viewsA: add a foreing key to an existing table
In SQL Server you can do so: ALTER TABLE Produto ADD IdSetorPreparo INTEGER, FOREIGN KEY(IdSetorPreparo) REFERENCES OrgSetor(id); If you want the column to admit NULLS you just have to set it to…
-
0
votes2
answers365
viewsA: ORDER BY COM GROUP BY to get last Row, sql
In response to the update of the question: Try this way to get the ID corresponding to the most recent date. SELECT MaxData.bold_count AS COUNT, U.ids, MaxData.born_data, MaxData.bold FROM users U…
-
1
votes1
answer71
viewsA: Definition and implementation in different locations
Just to serve as a small example, suppose the structure of your project is as follows:: Raiz |-inc | | foo.h |-src | | main.cpp |-bin | Contents of the files foo. h #include<string> class Foo…
-
5
votes2
answers15301
viewsA: Date formatting with Calendar dd/MM/yyyy
When you perform JOptionPane.showMessageDialog(null, "Data de inicio: " + contato.getDataInicio().getTime()); a call occurs to the Date.toString() method to display the contents of your variable. By…
-
2
votes1
answer13959
viewsA: Set default value for column of an existing table
Try it this way BEGIN ALTER TABLE Cadastro ADD IsPreparacao bit NOT NULL default 0 END The condition NOT NULL will cause existing records to be filled with the default value. A Constraint (NOT NULL)…
sql-serveranswered bruno 7,237 -
0
votes1
answer76
viewsA: Journey Boundary - SQL Server 2008
Calculating the difference between the two dates reliably is not very easy, but you can do the following: ;with cte as ( select chapa, data, min(cast(data as datetime) + cast(batida as datetime))…
sql-serveranswered bruno 7,237 -
10
votes3
answers10155
viewsA: Uppercase in the first letter of every word in a column in Mysql
This feature does not exist in Mysql, but you can set the following function to get the result you want. I consider this to be pure Mysql, so why reinvent the wheel, no? CREATE FUNCTION CAP_FIRST…
-
4
votes1
answer128
viewsA: How do you know if two periods intersect?
Assuming that the periods are correctly defined, that is, the start date is always prior to the end date, then this condition is sufficient to determine whether two dates intersect: (InicioPeriodo1…
-
1
votes3
answers183
viewsA: Return the difference between the last two records
In SQL Server you can do as follows ;with cte as ( select event_type, value, [time], dense_rank() over (partition by event_type order by [time] desc) rn from [events] ) select c1.event_type,…
-
3
votes1
answer91
viewsA: How to group comic book values?
You say in the question that you know the GROUP BY function and that you know how to group by a value. You can use this function to group across three columns, thus removing duplicate results. This…
-
4
votes1
answer2865
viewsA: Doubt in the implementation of the deep search in Graphs
The problem is where the instruction is pilha.pop(). This output should give you an indication of where the problem is: [A] [A, B, C] [A, B, C, F] [A, B, C, F, E] [A, B, C, F, E] [A, B, C, F] [A, B,…
-
1
votes1
answer224
viewsA: Signal and SLOT C++ with QT
You must include the macro Q_OBJECT in the Thread class. Of documentation: The Meta-object Compiler, moc, is the program that Handles Qt’s C++ Extensions. The moc tool reads a C++ header file. If it…
-
3
votes1
answer254
viewsA: Check if String contains commas
You can use the function find str = "Hello, World" if string.find(str, ",") then print ("Encontrou virgula.") else print ("Não encontrou virgula.") end If the search pattern is found the function…
-
2
votes2
answers2023
viewsA: Pass table field as parameter in a precedent
Do it like this: CREATE PROCEDURE pro_get_gastos @nome_tabela sysname, @data_mov sysname, @data_ini datetime, @data_fim datetime AS BEGIN DECLARE @sql nvarchar(4000) SELECT @sql = ' SELECT * ' + '…
-
0
votes1
answer200
viewsA: Constructor error parameterized c++
In C++ when you declare a parameterized constructor, the compiler will not generate the default constructor (constructor without parameters). Of standard 12.1/5: A default constructor for a class X…
-
1
votes2
answers384
viewsA: How to mount a select that brings information of which column is PK, which is not, and which is FK
You have another option, but using INFORMATION_SCHEMA you can do it as follows: SELECT UPPER(C.COLUMN_NAME) COLUMN_NAME ,LOWER(C.IS_NULLABLE) IS_NULLABLE ,LOWER(C.DATA_TYPE) DATA_TYPE…
-
2
votes3
answers52
viewsA: Mysql -> Assign Id’s to records
Mysql does not have the window functions (window funtions) of SQL Server, so you have to do it manually. I would SELECT @rownum := @rownum + 1 AS ID_RN ,t.ID ,t.ALDEIA ,t.DONO FROM aldeias t,…
-
3
votes1
answer171
viewsA: What’s the best way to do these triggers?
First of all, some comments on your implementation. In my opinion none of the cases justifies the use of a Trigger. The first Trigger aims, when a new user is inserted into the table TB_USUARIO,…
-
1
votes3
answers13820
viewsA: Calculate age per day, month and year
Try it this way: public static int calculaIdade(java.util.Date dataNasc) { Calendar dataNascimento = Calendar.getInstance(); dataNascimento.setTime(dataNasc); Calendar hoje = Calendar.getInstance();…
-
1
votes1
answer86
viewsA: ORACLE EXPLAIN PLAN, wrong values?
It is important to realize that the number 50 represents the estimate that the operator calculated based on the statistics it has at the time of execution. First of all you can try, if you have a…
-
3
votes1
answer9249
viewsA: Import . csv files to Mysql Workbench
Define a table with a structure that fits the contents of your file. The Product can be stored in a VARCHAR column. Here is an example you should change according to your specific case. CREATE TABLE…
-
4
votes3
answers7767
viewsA: Send email with CCO in PHP
According to the documentation multiple "additional headers" must be separated by CRLF ( r n). Only in some cases, and as a last resort, you should do as in your example and separate the headers…
-
0
votes1
answer92
viewsA: Optimization of SQL Query
You can try SELECT SUBSTRING(data_hora, 1, 13) + '00:00' AS 'Hora', COUNT(id_contato) AS 'Total' FROM contato WHERE data_hora LIKE '2015-06-10%' GROUP BY SUBSTRING(CONVERT(VARCHAR, data_hora), 1,…
-
1
votes2
answers222
viewsA: SQL Contar ROWS
The question has already been answered but, still, I leave a more concise answer that avoids the many sub-queries of the original solution. SELECT COUNT(DISTINCT CASE WHEN MinProduto = 1 AND…
-
5
votes2
answers531
viewsA: What is the correct way to get the device date?
System.currentTimeMillis() is the most efficient if your main concern is performance. Date() should be close in terms of performance as it is only an encapsulator of a (long) value in thousandths of…
-
1
votes1
answer15538
viewsA: How to run a trial in a select?
The use of stored procedures is not permitted in conjunction with the SELECT, WHERE or HAVING instructions. I can suggest an alternative. Create a temporary table to store the output of the stored…
-
1
votes1
answer708
viewsA: Subtract MYSQL Dates
Try it like this delete t1 from tabela t1 inner join ( select nome, count(nome) from tabela group by nome having (count(nome) >= 2) ) as x on x.nome = t1.nome where date_add(t1.hora,interval 5…