Questions tagged as 'sql'

1
answer

Using multiple group by in a query

I have 3 Tables: Products, Orders and Order Item. Table: Produtos id_produto foto_produto categoria sub_categoria --------------------------------------------------------- 0081 15487.jpg 4 32 0491 1...
asked by 08.12.2015 / 14:37
1
answer

Comparison of values with SELECT

Hello, I'm creating a search project and need to make a commit in my database. I have an "establishments" table in my SQLite database, with the following columns: id, name and category . And a String variable named " nameStab " I need to...
asked by 08.11.2015 / 00:39
1
answer

Refresh column with item sorting

Hello, In a given relationship table I have a column that holds the sort, however due to a problem in the application this column was populated with wrong data, as the example |user_log ------------------------------------------- |user_id...
asked by 22.07.2016 / 19:08
2
answers

Compare with previous date in oracle

Hello, I need to check which purchases have been made in the last 7 days select * from carros car where to_date(to_char(to_date(car.datacompra,'yyyymmdd'),'dd-mm-yyyy')) = trunc(sysdate - 7) I get the following error: ORA-01840: v...
asked by 25.07.2016 / 15:21
1
answer

Sort MySQL query for the last 3 months

I want to do an ordered SQL query for the first 3 months from the current month, for example: Current month is August (08), so I order as: 10 9 8 1 12 I am using the following command: SELECT * FROM 'tb_convencao' WHERE 'lg_historico'...
asked by 25.08.2015 / 19:10
3
answers

Return the difference between the last two records [closed]

What I need to do is in this image. How do I do it? This is the query I made and it is coming empty and I do not know why. SELECT event_type, value from teste t1 Where exists (select event_type, value from test...
asked by 29.06.2015 / 21:04
1
answer

SQL Server joining tables with null

I have the following tables: Responsavel | Filho Id Nome | Id Nome ResponsavelId 1 Ana | 1 Aninha 1 2 Maria | 2 Ana Júlia 1 3...
asked by 04.08.2015 / 16:31
1
answer

How to do a query with different table conditions

   REGISTRATION TABLE A        Attributes: Code, name, type       TABLE NUMBER B        Attributes: Code, number       TABLE C PERSONNEL        Attributes: Code, gender I need to bring the name and type information from table A with corr...
asked by 01.05.2015 / 03:43
1
answer

Reset to self-increment

I have a problem with my base fingers. I have the sending code as auto increment but whenever I delete a sending code the value does not reset or is not restarted is always increasing. I wanted to know how to reset the number ... for example...
asked by 23.05.2015 / 16:22
1
answer

Error creating a NOT NULL field in PGADMIN "contains null values"

I have a database already created, inside it I have a table already created. In it I need to create a field that is NOT NULL . I do everything via the graphical interface that is faster, I click on the > new column : table, giv...
asked by 01.04.2015 / 15:01