Questions tagged as 'sql'

1
answer

Postgresql Autoincrement skips 1 value when the insert is made by a function

I have the following function in Postgresql : CREATE OR REPLACE FUNCTION ve.geraHistorico() RETURNS VOID AS $$ DECLARE i INTEGER := 1; id INTEGER; dataCad TEXT; dataFec TEXT; qtd INTEGER := (SELECT COUNT(id) FROM ve....
asked by 04.07.2018 / 19:42
2
answers

How to use the SUM aggregation function in a NHIBERNATE query?

My query consists of knowing NumCarroId , TotalGasto and VlrUnit , in Sql I could do this but when I play in HQL it returns the following error: Applying GROUP BY to SUM to make a ToList, to show...
asked by 17.01.2018 / 17:25
2
answers

Check in a table if a user is not registered

Colleagues, I have a table called salas_usuarios, this table contains all the users registered in the rooms and another table called users, where I store the users. But I would like to check which users are not registered in a certain room. T...
asked by 30.06.2016 / 23:22
3
answers

Problems with SELECT RIGHT JOIN

I have two tables, A and B. In Table A, I have a column with machine names (Cortadeira, Baler, Packer and Rewinder) and in the other column some causes that made them stop Lack of Electric Power, Coil Replacement, etc). In Table B , I have a...
asked by 07.03.2018 / 12:29
1
answer

Merge columns into a single SQL column

I have three columns, belonging to the same table in the database, these being: Growth, Financial Autonomy and RaciLiquidity; All columns are of type bit. What I need is to group all three fields into one column, that is, if I do: SELECT Is...
asked by 13.03.2018 / 11:37
2
answers

How to put simple apostrophes and concatenate with a string?

I have a question, I want to be able to concatenate a String, so that it is interpreted with simple apostrophes between it. For example, SQL would look like this: SELECT IDALUNO, NOME, DATANASCIMENTO FROM ALUNO WHERE DATANASCIMENTO BETW...
asked by 18.03.2018 / 20:17
1
answer

Command to display a limit of records in a table

Assuming a database has a locacoes table, which SQL command would display between the tenth and twentieth registers of this table, sorted by field titulo ?     
asked by 30.08.2014 / 02:27
1
answer

Select with Inner join too slow

I have a problem where select is bringing the right result, but it takes too long. Follow the select: SELECT c.cod_paciente, p.nome, i.valor, i.quantidade, d.convenio, c.cod_conta FROM caddadosclinico d INNER...
asked by 05.01.2018 / 20:26
3
answers

SQL Query - Doubt Condition Dates

Everyone, good afternoon! I'm having trouble with the query below. I want you to bring all the tasks only when the maturity (field) of them is equal to the month after the opening date (tardata). However, nothing came up in the query. select *...
asked by 01.12.2017 / 19:04
1
answer

How to make a query in sql that returns the data of a table when the data is empty? [duplicate]

Well, I created a table called installments, which when the customer pays it is entered 'PAYMENT' in the column situation, and when not paid it remains blank. I wanted to get the information from this column to know when the account was not pa...
asked by 29.10.2017 / 16:09