Questions tagged as 'sql'

2
answers

Sql - Natural Ordering - Varchar

Situation I need to perform the natural ordering of the string. Example Processo 1 Processo 2 Processo 3 Processo 10 Processo 11 Processo 12 Order Pattern. (ASC) Processo 1 Processo 10 Processo 11 Processo 12 Processo 2 Processo 3...
asked by 15.10.2015 / 16:53
1
answer

How do I add multiple phones to the same form dynamically?

I'm studying PHP and SQL and I'm building a system so that my mother can better manage all the clients who use the transport service she provides. I built a simple registration page with the necessary information, and would like...
asked by 01.02.2016 / 17:51
1
answer

Get the previous record of a date

I need to make an appointment, where I need to get the penultimate record, that is, the previous record and the date as well. SELECT DISTINCT prt_partner.razao_social, prt_partner.end_cidade, prt_partner.end_estado, prt_partner_status.nome, (...
asked by 29.03.2017 / 19:17
1
answer

SQL script, to insert emails into a table, and then change them

I have a script, which makes random insertions of emails into a table, after these inserts, I need to find a way to recheck those inserted emails, and change them This is a part of Script, I give him a lot of emails (for example 5), and he wi...
asked by 12.06.2018 / 15:02
1
answer

Postgress Crosstab - return and sql tuple descriptions are incompatible

I'm trying to use crosstab in postgres but ... CREATE TABLE tb_testect ( datahora timestamp without time zone, teste integer ); * Fix INSERT INTO tb_testect VALUES (TIMESTAMP '2016-01-01 08:30:00',1); INSERT INTO tb_testect VALUES (...
asked by 17.10.2016 / 16:02
2
answers

Select inverting row and column

I have a table like this: codigo ano quant 100 2014 15 100 2015 13 100 2016 20 101 2015 15 102 2016 22 102 2014 05 I want to create a query that lists the code like this: codigo 2014 2015 2016 1...
asked by 04.11.2016 / 15:36
1
answer

Get the max value inside a while that is inside a cursor

My question is this: I have my cursor for the interaction line by line and inside it I have a while for horizontal interaction. I'm trying to populate a table whose PK does not have identity , using MAX and setting +1 in w...
asked by 25.08.2015 / 20:21
1
answer

Duplicate Registry - Firebird

In Firebird how to delete duplicate records, keeping only one of them? Could you help me. I have this select, however it deletes all logs, I use firebird 2.1 delete from vendaproduto where vendaproduto.pro_codigo in (select ven...
asked by 26.08.2015 / 13:02
1
answer

Select with Update

Would anyone know if there is a SQL layer to run a SELECT using LOCK IN SHARE MODE in the registry and running an UPDATE at the same time? example: SELECT * FROM Nome_Tabela WHERE id = 5 LOCK IN SHARE MODE (UPDATE AQUI) Any su...
asked by 21.07.2015 / 19:16
1
answer

Difficulty in grouping and where clause in MySql

I need to search the database for the last 4 most recent records, with the exr_exa_id column matching the reported id's, and exr_exa_id can not be duplicated. I tried to group in a few ways, but I was not successful, because it...
asked by 13.08.2015 / 20:30