Posts by Pedro Costa • 503 points
28 posts
-
0
votes2
answers293
viewsA: Replace string chunk between 2 indexes
If you’re going to apply several rules, you might want to read line by line. replace it will replace only the first one it finds, not the entire string. Then you would have to make a loop for it to…
-
5
votes3
answers1292
viewsA: How to loop 'for' in 1 line?
To have the for in a row, just do: print([rank for rank in range(4)]) You need to put it between the "[" and "]" brackets to work, otherwise error will occur. It is also possible to apply filters,…
-
0
votes3
answers628
viewsA: Create a custom SQL order
For SQL Server, it could be done as follows: UPDATE groups SET groups.display_order = X.ORDEM FROM groups INNER JOIN ( SELECT ROW_NUMBER() OVER(ORDER BY id) AS ORDEM, * FROM groups ) AS X ON X.id =…
-
1
votes1
answer280
viewsA: Return data from two identical tables [SQL] [Python]
You can use FULL OUTER JOIN: SELECT TABELA1.*, TABELA2.* FROM TABELA1 FULL OUTER JOIN TABELA1 ON TABELA1.Chave = TABELA2.Chave You can use UNION ALL: SELECT * FROM TABELA1 UNION ALL SELECT * FROM…
-
0
votes1
answer39
viewsA: Plot Pivot (Row in column)
Maguim, as I mentioned in the comment, what is inside the IN is the identifier of the pivot column, for you to understand better, it must be the element that is in the line. By the data provided, I…
-
1
votes2
answers36
viewsA: Retrieve a random value from a predefined number list
Sql has a function that returns a random number between a range (RAND()), puts to run a RAND() for each row of the table and sorts it by this column, searching also for the ID field and assigning to…
sqlanswered Pedro Costa 503 -
1
votes1
answer213
viewsA: How often a string appears in a table in each record (SQL Server)
Dude...I think the easiest way to do this is gonna be this one, yo: DECLARE @VAR VARCHAR(50) = 'TAG' SELECT (LEN(CAMPOXML) - LEN(REPLACE(CAMPOXML,@VAR,''))) / LEN(@VAR) You take the field size…
-
1
votes3
answers119
viewsA: How do I reset the Flask server using if within the algorithm?
Can you do this using a class, if it is the most suitable and most recommended way? Probably not. Generally Apis are built to be stateless, meaning they don’t keep the "status" of the information…
-
0
votes1
answer1642
viewsA: Limit decimal places - SQL Server
The simple way is this: select liv_titulo, liv_preco as preco_atual, CONVERT(DEC(10,2), liv_preco + (liv_preco / 100 * 10)) as preco_adicao, CONVERT(DEC(10,2), liv_preco - (liv_preco / 100 * 10)) as…
-
0
votes1
answer74
viewsA: Result in a Python Dataframe
You can do so: #import numpy as np import pandas as pd import psutil as ps names = [] for service in ps.win_service_iter(): info = service.as_dict() names.append({ 'nome': info['name'],…
-
0
votes1
answer104
viewsA: How to select only the first row of row_number
SELECT MAX(X.U_PERLET) AS ANO, X.RA, X.NOME, [...] FROM ( SELECT SA.RA, PP.NOME, SC.COMPLEMENTO, SPL.ANO, ROW_NUMBER() OVER(PARTITION BY SA.RA ORDER BY SPL.ANO ASC) AS U_PERLET FROM [...] ) AS X…
sql-serveranswered Pedro Costa 503 -
1
votes1
answer139
viewsA: Turning binary into a Python chart
I don’t know if you have to apply some rule (you didn’t specify in the question and I honestly don’t know what this pattern is about), but basically, if you want to make the image graph, just use…
-
1
votes2
answers687
viewsA: TOTAL row with the SUM of columns using PIVOT
You can do it this way: CREATE TABLE TESTE (MES INT, VALOR INT); INSERT INTO TESTE VALUES (1, 1000); INSERT INTO TESTE VALUES (1, 1150); INSERT INTO TESTE VALUES (1, 1200); INSERT INTO TESTE VALUES…
-
0
votes2
answers840
viewsA: Update in a column using more than one return
Update with FROM this way: Mysql: create table produto(clientid integer, valor integer); create table produto2(clientid integer, valor integer); insert into produto(clientid , valor) values(1, 100);…
-
5
votes1
answer442
viewsA: Adding a column of numbers 1 to a numpy array
The np. c_function basically creates two columns with the arrays informed: if you inform: np.c_[np.array([1,2,3]), np.array([4,5,6])] he creates: array([[1, 4], [2, 5], [3, 6]]) The np.ones()…
-
4
votes2
answers354
viewsA: (Query SQL) Limit the number of rows in a select with Inner Join and Where in
It is possible to use the ROW_NUMBER to establish an index for the category thus with the PATITION BY, every time it is a new category, it restarts the index. Put this as a subselect and on WHERE of…
-
0
votes1
answer160
viewsA: Python Encoding Problem
From the Request documentation: documentation request It is possible to change the formatting: import requests r = requests.get('https://api.github.com/events') r.encoding >>> 'utf-8'…
-
3
votes2
answers928
viewsQ: How to hide Axios request data in Javascript (JS Node)
Hello, I’m developing an application and setting up a user registration screen, but I’m wondering if it’s possible to hide the data that Axios is requesting for the API. My Javascript code, which I…
-
1
votes2
answers114
viewsA: Width defined in css appears as Undefined for Javascript
Use "offsetWidth" to access the value that is in CSS style: ** note for the ";" in the code and the concatenation of "px" in: elem.style.width = newBegining + 'px'; const initial = 10; const end =…
-
1
votes1
answer31
viewsA: Style sheet in input
You weren’t very clear in your question, I don’t know if I understood, but see if this is it: CSS and HTML: table { border-collapse: collapse; } tr:hover { border: 2px solid blue; } .borda-vermelha…
jqueryanswered Pedro Costa 503 -
0
votes3
answers3992
viewsA: Convert Date to year / month
SQL provides some ready time and date conversions, here is a tabelinha: https://www.mssqltips.com/sqlservertip/1145/date-and-time-conversions-using-sql-server/ As the link, could be being done so:…
-
0
votes2
answers1396
viewsA: Loop inside loop While PYTHON
You can add an "auxiliary" variable to this and place the trial assignment part and a new number inside the Loop, this way: import random import time from sys import exit…
-
0
votes1
answer57
viewsA: DATE CRITERIA ENTER A SUBQUERY - SQL
Try this: SELECT * FROM ( SELECT PSECAO.CODIGO COD_SECAO, PSECAO.DESCRICAO SECAO, PFUNC.CHAPA CHAPA, PFUNC.NOME NOME, PFUNC.CODSITUACAO SITUACAO, (SELECT MAX(PFHSTFER.DTINIPERAQUIS) FROM PFHSTFER…
-
-1
votes1
answer169
viewsA: How to know the number of films by categories that have less than 50 films?
Try this (if you are using SQL Server): SELECT NOME_CATEGORIA, COUNT(ID_FILME) AS QTD FROM TABELA1 (NOLOCK) INNER JOIN TABELA2 (NOLOCK) ON TABELA1.ID_CATEGORIA = TABELA2.IDCATEGORIA GROUP BY…
-
3
votes1
answer1193
viewsQ: Web scraping with Python (Selenium and Request)
Hello, I am trying to perform a web scraping on a page protected by login, I have already managed to access both via Request, and via Selenium, the problem is after login. The page is as follows:…
-
0
votes1
answer429
viewsQ: Pyserial library problem (PYTHON)
I am trying to control Arduino by a Python script through the "pyserial" and "serial" library. But every time I run the code it misses the first few lines: import serial ser = serial.Serial('COM7',…
-
0
votes3
answers2912
viewsA: Create Trigger with update setando field through a function
I needed to create a view, it’s an embedded system, probably the order in which the tables are populated doesn’t work with the ones I’m checking. In summary: I created the view with the searched…
-
0
votes3
answers2912
viewsQ: Create Trigger with update setando field through a function
I’m looking to use a trigger to update the field of a table whenever there is an Insert in this same table. The problem I’m having at Trigger is that the update doesn’t work, it follows Trigger:…