Questions tagged as 'sql'

1
answer

last_insert_id oracle

I have a question about oracle bank. I created two tables and set one of them with a field with foreing key (see below FK) tbl_city * id_city * (PK and auto increment) - generated with sequence since we do not have auto_increment in orac...
asked by 15.02.2014 / 13:42
3
answers

Filter table before applying a LEFT JOIN

I have two tables and I want all elements of the first one - regardless of the JOIN condition (which characterizes a LEFT JOIN) - but before that I want to filter the second table. For example: Client table: ╔══════════╦═══════╗ ║ C...
asked by 19.02.2014 / 20:48
1
answer

MYSQL, How to do SELECT without grouping identical WHERE values?

Good Afternoon SELECT id, descricao FROM Produtos WHERE id IN ('1','1','2', '3','3'); But the result is id / descricao 1 / Caneta 2 / Lapis 3 / Borracha I wanted it to look like the table below id / descricao 1 / Caneta 1 / Caneta...
asked by 20.11.2018 / 18:18
1
answer

INNER JOIN in 4 tables

I have 4 tables: TB_OS_MANUTENCAO: TB_OS_ELETRONICA: TB_OS_MECANICA: ETB_OS_INFORMATICA: As shown in the screenshots, all tables have one field in common, the call_id, and also with a common value, 8. This field is not marked UNIQUE a...
asked by 24.10.2018 / 00:52
1
answer

How to group data per week in mysql [closed]

I am extracting some data and want to know some way to group the data by week. I am giving SELECT and it is bringing the data from last month and I am already grouping by day, but I need it to be per week.     
asked by 17.10.2018 / 15:24
3
answers

Help with select in MYSQL [closed]

I would like to know how I do to list the oldest customers for each city, I tried several commands but without success. I would like you to quote automatically. Here are some commands I used, but I did not get the expected result. selec...
asked by 17.12.2018 / 02:53
1
answer

Sql using left join

I have the following tables: TB_ESTOQUE |PRODUTO|QT_DISPONIVEL|COD_FILIAL| |0856322| 5 | 41 | |0856351| 2 | 41 | |0856322| 9 | 114 | |0856720| 3 | 20 | TB_FILIAL |COD_FILIAL|COD_L...
asked by 08.10.2018 / 21:57
1
answer

COUNT with conditions and selection without WHERE at the end

In my table I have 3 columns: % auto_default% id(INT) : values are tipo(INT) or 1 2 I need a medium without the id_usuario(INT) at the end to know if there is a specific data of the user, and if ther...
asked by 29.09.2018 / 18:03
1
answer

Return 3 previous months from day 1

Every Friday I need to generate a report that brings me transactions made in the last 3 months. However, I have to pick up from the 1st of each month, for example, we are in month 9, so I have to pick up all the transactions since 01/06. I alway...
asked by 28.09.2018 / 17:37
1
answer

Grant permission to a new user in SQL Server 2014

I'm trying to assign permissions of db_datawriter and db_datareader to a new user in SQL Manager The following steps have been performed: -- criação do usuário CREATE LOGIN apostila WITH PASSWORD = 'qweQWE123!@#'; -- usuári...
asked by 18.09.2018 / 22:19