Questions tagged as 'sql'

1
answer

Problem with dynamic UPDATE in PDO

I'm creating a CRUD dynamic in pdo , where I get several parameters inside an array, and inside this array there can be several other arrays. The problem is when I'm mounting SQL. I asked a similar question here , but the solution was not...
asked by 14.12.2015 / 18:58
2
answers

SQL Server: how to create range of values based on a column with monetary values

Hello, community! I need a SQL query with the values of a table field of SQL Server 2012 shown as frequency distribution. Let's say I have the field Sales (in R $), type float. The lowest sale recorded was R $ 0.01 and the highest of R...
asked by 30.11.2015 / 20:46
1
answer

Grouping and Summing in Oracle

I have a Customer registry ID NOME GRUPO 2033 JOAO FORNECEDORES 2044 MARIA MANUTENCAO 2055 JOSE FORNECEDORES And I have a purchase record made by each customer ID_CLIENTE VALOR_COMPRA 2033 4.000 2033 1.130 2044...
asked by 05.05.2017 / 15:14
1
answer

Revoke privileges

I have a database and I'm trying to make only my user have access to that database. or no one else can open, search, delete anything. I'm using the following syntax: GRANT USAGE ON batabase.* TO 'fabricio'@'%'; FLUSH PRIVILEGES; But nothi...
asked by 07.02.2015 / 12:18
1
answer

Is it possible to create a decision structure in a table in SQL?

I have a massive database, it has more than 2,000 rows, and the second column has an ENUM that allows only 'Option 1' and 'Option 2'. If I enter 200 rows in the table and write the wrong ENUM name as an example insert into tabela values ('bla...
asked by 01.11.2014 / 13:41
2
answers

What is the best way to create a conditional foreign key constraint?

In some cases, it is interesting to create a conditional foreign key reference , that is, it does not allow you to reference all the records in another table, but only those that assume a condition. For example: If you have a people table...
asked by 21.11.2014 / 19:12
3
answers

Query with conditions in SQL SERVER

Follow the tables below with my question I have a problem in which to make a filter where I need to pick up the posts that have the post_pai column from the post table with a value other than 0, and I also need to check if the post_addr...
asked by 17.08.2016 / 15:38
1
answer

Make calculation with the result of select

How can I make a calculation on the select below? I made sums of amounts and amounts, now I need to take these sums and make a balance. It would look like this:    qtd_tipo_0 - qtd_tipo_1 - qtd_tipo_2 and    total_type_0 - total_typ...
asked by 12.05.2016 / 19:44
1
answer

When to use WITH (NOLOCK)?

Select * from MinhaTabela with (NOLOCK) I know colleagues who always insert the With (NOLOCK) clause in their selects and I know others who preach that NOLOCK is bad practice and should never be used. Some claim that with NOLOCK we hav...
asked by 20.05.2016 / 21:33
3
answers

Firebird, insert with where not exists

I'm trying to insert a record into the table, but this record will only be inserted if it does not already exist there, so I'm trying to do it like this: INSERT INTO R01 (NUMERO,EXPORTADOR, IMPORTADOR, DATAANTECIPADO, STATUS) VALUES (64, 'CCB...
asked by 20.07.2015 / 16:07