Posts by Lisângelo Berti • 112 points
13 posts
-
0
votes1
answer59
viewsA: Analyze the last 3 records of a table using PHP
Create a calculated field in select that signals whether or not the value is below 50: select preco, if preco < 50 then 'S' else 'N' endif as preco_menor from tabela order by data desc limit 3 so…
phpanswered Lisângelo Berti 112 -
0
votes4
answers3251
viewsA: Select first name? - Select in bank
First test if there is more than one word in the field, if there is return to the first, if there is no return all content of the field: SELECT instr(NOMEJOGADOR, ' ') AS pos_espaco, CASE WHEN…
-
0
votes2
answers865
viewsA: Select to know customers without service in the last 30 days plsql
Select * from tabela where DTULTCOMP is null or DTULTCOMP < (SYSDATE - 30) If you want to know only those who actually bought something, because there are customers who bought it a long time ago,…
-
0
votes3
answers8232
viewsA: A register of people in python
Use print() with formatting options: print("Id: %s, Nome: %s" % (mostrar2[0], mostrar2[1])) The %s option can have more arguments such as a minimum size: %S20
pythonanswered Lisângelo Berti 112 -
-2
votes3
answers200
viewsA: Select bringing maximum Columns with Writing - MYSQL
Count() with group by select referencia, count() as qtd from tabela group by referencia
-
1
votes1
answer310
viewsA: Export Text field to Bytea in Postgresql
Use the function convert_to that returns bytea: update tabela1 set campobytea = convert_to(campotexto, 'UTF8') where (codigo = 1234)
-
1
votes2
answers4035
viewsA: Generate Postgresql Server backup with password via command line
Create a text file '.pgpass' in the user folder with the line "hostname:port:database:username:password". P. ex.: 127.0.0.1:5432:<nome_database>:postgres:<password> and in the pg_dump…
-
2
votes2
answers493
viewsA: How to do if in sql - Postgres
No need for IF, use OR: where log."data" BETWEEN '2018-01-01' and '2018-06-30' and log."tipomovimento" IN ('S') and (log."nomefornecedor" = null OR "nomefornecedor" = 'x')…
-
1
votes2
answers197
viewsA: What is the range defined by range in Python?
Will generate 0, 1, 2, 3 and 4 Normally, the first range parameter is the initial number, the second is the final but excluding one. In its example, range(5), python assumes that the initial…
python-3.xanswered Lisângelo Berti 112 -
0
votes3
answers255
viewsA: Calculate percentage between two MYSQL dates
You are calculating the total 'SELECT Count(*) as total from questionario' always with all the records of the table while calculating the percentages by filtering the dates with the 'between'. To be…
-
1
votes1
answer44
viewsA: Query that changes the amount of items in Mysql
To query SELECT * FROM lentes returns all registered lenses. There should be no clause WHERE for the specific lens ($idad)?
-
-1
votes3
answers76
viewsA: Is there any difference in performance depending on what you seek?
It depends on the amount of information recorded. If you allow the search for only one record, 'a' say, which is very common, in a database of considerable size, the return could be an excessive…
-
1
votes4
answers90
viewsA: Is there a difference in these two querys?
A lot of difference. When we put a parenthesis, everything within it will be considered only a result. In your example, the first select has THREE INDIVIDUAL conditions: it will bring all records…