Questions tagged as 'sql'

1
answer

Help with logic in SELECT

I have a "matchmaking" script (as if it were a game). He checks every 3 seconds a table to see if there are 10 players who are not playing. But I also need to check if these 10 players are one of them. The select is like this $busca_db_qtd...
asked by 19.07.2018 / 17:05
1
answer

How to create a named Primary Key constraint in Postgres?

I'm continuing to create a primary keyless table initially. Then I add a id field of serial type and try to create the constraint for the Primary Key (PK): create table macaco( nome varchar(50), idade integer ); --adicionando o id do...
asked by 16.08.2018 / 17:22
1
answer

UPDATE with multiple records from another table

I have a T1 table where I have ID . I have a T2 table where it gets the ID_T1 ( Foreign Key ) of T1 . I have a T3 table where it gets the ID_T1 ( Foreign Key ) of the T1 and the ID_T2...
asked by 11.07.2018 / 15:52
2
answers

Doubt when creating table with dates in postgresql

I have the following table structure: Iwouldneedtocreatea3rdtablethatwouldlooklikethis: I have the smallest and longest date in a table and in another table I have changes made, I would need to create a script that would generate a 3rd...
asked by 06.07.2018 / 00:09
1
answer

Pick up the time of day

I have the following select to pick up the time of day SELECT '00:00' AS A UNION SELECT '01:00' UNION SELECT '02:00' UNION SELECT '03:00' UNION SELECT '04:00' UNION SELECT '05:00' UNION SELECT '06:00' UNION SELECT '07:00' UNION SELECT '08:00'...
asked by 24.07.2018 / 14:58
1
answer

Case with parameter in Interbase 2017

Good night everyone, I've always used Firebird, but I decided to try the interbase 2017 for mobile applications. The following SQL works normally in Firebird and SQLite. But I'm breaking my head to try to make it work in Interbase 2017. If I rem...
asked by 28.07.2018 / 03:11
1
answer

How to insert grouped data from one table to another SQL

I have a 'point' table, with columns (id, pis, date, time), which record the input and output of a product ('pis'). I wanted to group it into another table, where the data, pee and date, are the same group all the 'time' data are grouped into a...
asked by 01.08.2018 / 15:07
1
answer

Return of the maximum value

Good morning, I'm taking a course and I'm stuck in an exercise. In the exercise I have to return the maximum value of popularity of each musical genre by country, so far so good, I managed to carry out the procedure, the problem is that in th...
asked by 29.06.2018 / 14:18
0
answers

Different results 'count (*) from V $ ASM_DISK'

I have a script that connects to an Oracle database and then selects: select count(*) from V$ASM_DISK; This script is in a .sql file, so I make the following call in the OS: "$ORA_HOME/bin/sqlplus -L -S xxxx/xxxx @query.sql"; When exec...
asked by 20.06.2018 / 17:36
1
answer

Manipulation of sql temporary tables in delphi

Good afternoon I create in Delphi a temporary Sql table, that is, it does not exist physically. I can even write data to it, but I can not put the information in a dbgrid: 1) I created the table like this: qryCIDtemp.SQL.add('Create table '...
asked by 21.06.2018 / 20:08