Posts by chegancasb • 366 points
28 posts
-
0
votes1
answer32
viewsA: DISTINCT in a WHERE Oracle
Repurposing most of the steps taken. The idea here is to use the date field to remove duplicates, then at the same time we get the sort. On the outside, we keep only the first N entries (2). SELECT…
-
1
votes1
answer33
viewsA: Duplicate column of a table for itself by changing only the ID
I will use a simplified version of the original table to exemplify the solution. The solution for the final table is the same, adding the remaining fields. The advantage of this approach is that…
-
0
votes1
answer17
viewsA: Store as much data as I want in a tebela column in oracle Apex
If a fine can have more than one motive then the relationship between the fines and the motives is 1-N. In this way a third table is needed that relates each fine to its various reasons. Something…
-
0
votes1
answer40
viewsA: Display non-zero values
Well, I start with a phrase "Just because you can do something doesn’t mean you should do it." The solution presented only serves to illustrate what can be done using only basic validations between…
-
0
votes1
answer18
viewsA: Dúvidas Group by (ireport)
You must repeat ALL fields displayed in the SELECT list. In general the clause GROUP BY is used as follows:: SELECT <Lista de campo a apresentar 0 ou mais>, <Lista de funções agregadoras…
sqlanswered chegancasb 366 -
1
votes1
answer28
viewsA: How to organize a Mysql table efficiently and scalably?
Without knowing the intentions behind the code or how this table relates to the other tables is difficult to give opinions but something that jumps me to the view are the multiple columns with the…
-
0
votes1
answer44
viewsA: Doubt with relation of Mysql tables
Why not a 1-M ratio? The same product can be changed several times, so table entries updates will have a reference to the table entry products to which the amendment refers. In challenge mode, the…
-
0
votes1
answer20
viewsA: Trigger (Trigger) in phpmyadmin is copying multiplying records
Note that you are not applying filters to the query. That way you are always selecting the entire table. You must filter select (from Insert select) by the line that has been inserted. Try to put…
-
0
votes1
answer50
viewsA: I am making an online calendar and can not have 2 schedules scheduled on the same day and at the same time for the same professional Mysql PHP PDO
The problem you are trying to solve with the search is solved in DB and not in the code. At first, if you set the user identifier (prof) and the time of service (start) as a single key, your problem…
-
0
votes1
answer76
viewsA: SQL Plus - Export CSV without Query in File
This is a consequence of how the commands are being processed by Sqlplus. The parameter SET ECHO OFF (see description below taken from documentation) allows this but because they are redirecting the…
-
0
votes1
answer57
viewsA: Subselect and concatenate the same Oracle column result
I suggest something like this: I also suggest adopting the use of ANSI syntax for JOINS which, in addition to being common to most SQL implementations, makes reading easier (and has no implications…
-
0
votes1
answer30
viewsA: Can I not use a Trigger correctly in MYSQL?
Reinforcing my comment. CREATE TRIGGER inventory_update_purchases AFTER INSERT ON purchases FOR EACH ROW BEGIN UPDATE products SET products.inventory = products.inventory + NEW.inventory_bought…
-
0
votes1
answer30
viewsA: Result for a Mysql query
I suggest applying the keyword DISTINCT, right after the SELECT in order to remove duplicate entries. SELECT DISTINCT usuarios.modalidade, produtos.idproduto, produtos.nome, produtos.referencia,…
-
0
votes1
answer39
viewsA: group each period per month
You have to transform the date field ent_datahora_entrada in such a way that it has the desired format. In this way: select ent_datahora_entrada as mes, veiculos as periodo , count(*) from ( select…
-
0
votes1
answer41
viewsA: Turn row into columns using pivot
How about the following solution: WITH HOURS AS ( SELECT LEVEL AS PERIOD FROM dual CONNECT BY LEVEL < 24 ), TABLE_A AS ( SELECT UPAI.ST_NOME AS ST_NOME_SUPERVISOR, To_Char(A.DT_CRIADO_EM,'HH24')…
-
0
votes1
answer24
viewsA: How to create a read sequence in a Select field in the Oracle Database?
Oracle has sequence functionality. See the link below for more details. Summarily, to create the sequence: CREATE SEQUENCE customers_seq START WITH 1000 INCREMENT BY 1 NOCACHE NOCYCLE; But from his…
-
0
votes2
answers148
viewsA: save Fibonacci sequence in C
You are not specifying the creation of a new line. Includes the value \n in instruction fprintf to create a new line. (...) fprintf(teste,"%d\n" ,aux); (...) Note, at another point: You should only…
canswered chegancasb 366 -
0
votes1
answer18
viewsA: I made this code Join, I got it to return the expected values, but the values appear repeated. (Obs: I am beginner in Database)
Not knowing the structure of the table, it seems that the field CLI_BAI_CODIGO only belongs to one column (otherwise the BD engine would complain that it could not know to which table the field…
-
2
votes1
answer228
viewsA: How to view month and year only oracle sql
Mysql or Oracle? I will assume Oracle once it appears in the subject and that the field containing the date is dt_location. If this field is of date type: SELECT MAX(nr_pedido), SUM(vl_total),…
-
1
votes1
answer48
viewsA: Change global branch to main in Ubuntu 20
The command git-config allows this. The parameter init.defaultBranch, as the documentation says, it allows you to define another name for the branch used in the creation of a new repository or when…
-
-1
votes2
answers51
viewsA: SQL Locates duplicate releases and brings another table data
Assuming that the table has, in addition to the fields it indicates, a field that uniquely identifies each input, which example pair we call ID. With the expression below, we get only one result for…
sqlanswered chegancasb 366 -
1
votes2
answers98
viewsA: How to remove the Comma from the last occurrence [PERL]
Without recourse to regex, one can do the same by changing the order of the actions. The comma is added before each member from the second iteration. open(FILEHANDLE, '<', 'prices.json'); my…
-
2
votes2
answers28
viewsA: How to identify the absence of a term in a file using PERL
You can use a variable that records whether the pattern was found. For example: my $found=0; for($i=0; $i<=$#report; $i++){ if($report[$i] =~ /target/){ chomp $report[$i]; print "$report[$i]";…
-
1
votes1
answer555
viewsA: Is there a way to create a valid certificate for Apache localhost?
By localhost design is not a recognized domain outside of a PC and therefore is not allowed by public certificate issuing authorities (CA’s - such as letsencrypt.org) to generate publicly recognized…
-
0
votes2
answers995
viewsA: is not a GROUP BY expression
Re-formatting the SQL expression: SELECT C.NRO_CONTA, C.NOME, C.SALDO , ROUND(SUM(FA.COTAS * FA.VALOR_COTA),2) AS SALDO_APLIC FROM CONTA C JOIN ( SELECT FA.NRO_CONTA, FA.COD_FUNDO, FA.NRO_COTAS AS…
-
0
votes2
answers439
viewsA: REGEX - denying prepositions in the name of public places
Assuming that each address has only one preposition and we only look for the prepositions "DE", "DA" and "DO", we can simplify the comparisons using the expression: /^(.*?)((?:\sD[AEO])(\s.*))?$/…
-
0
votes1
answer50
viewsA: Help for designing mysql query
I would say that this search summarizes the table information in order to obtain the intended. SELECT case when d1=1 or d2=1 or (...) d15=1 then 1 else 0 as dx1 count, case when d1=2 or d2=2 or…
-
1
votes2
answers4216
viewsA: Function MAX only 1 (one) record on Oracle
Assuming that there is only one entry with the maximum value of the desired column (for the conditions placed), the question can be solved in this way: SELECT ID, TICKET_ID, QUEUE_ID FROM…