Questions tagged as 'sql'

1
answer

Get rows of at least 3 days ago

I have a table with column datetime and I need to get the results that already have 3 days of existence, all with more than 3 days, I tried to use SELECT *, DATE_FORMAT(date, '%m/%d/%Y') FROM tb WHERE DATE(date) = CURDATE() - INTERVAL 3...
asked by 14.01.2015 / 23:52
1
answer

Doubt mySQL and Left Join

I have the following SQL, which returns data that will fill some inputs of a form. The problem is that I have 20 items (pieces) in this table, but it can be empty because the user can fill any amount. The description of the piece is in her table...
asked by 07.03.2016 / 18:30
2
answers

Query relationship too much for many SQL server

Hello, I have a question to make a select on SQL SERVER . I have 3 tables. They are, BOOKS, AUTHOR and BOOK_AUTOR . A BOOK_AUTOR has a foreign key of BOOKS AND AUTHOR . I need to make a id that returns all books with...
asked by 21.03.2016 / 04:44
1
answer

Trigger that calculates and updates age

I want to create a trigger that, when triggered, calculates the age of the client in each row of the table and updates if necessary. I tried the following: create trigger Atualiza_Idade on cliente for insert,update,delete as declare @i in...
asked by 05.03.2015 / 18:08
1
answer

How to improve the performance of this SQL query?

Hello, I'll first pass some pertinent data to the query. Tabela Contrato (id, id_cliente, status [ativo/inativo]) Tabela Cliente (id, nome) Tabela Dependente (id, id_cliente, nome, status [ativo/inativo]) Tabela Cartao (id, id_cliente, id_depe...
asked by 09.03.2015 / 06:00
2
answers

How to make rounding every 5 tenths (0.5)?

I have a select that returns the average of the columns. I used the Round to remove some decimal places and round the numbers. The possible numbers of the fields are integers from 1 to 5, and when the average is selected, the decimals appear....
asked by 11.06.2014 / 16:50
2
answers

Object Variable type and expressions

I would like to know if there is any way to mount an expression in ssis that returns true or false in a variable of type object: It would basically be something like in sql 12 in (14,25,45,12,54) but expression instead of a list would be some...
asked by 17.11.2014 / 16:42
1
answer

How to list the highest salary among all employee functions?

People, I want to know how to list only the function that has the highest salary and not the highest salaries of all functions, does anyone give me a light? Here's how I'm doing: select max(Salario) from Funcionarios group by Funcao; I also...
asked by 20.08.2016 / 20:01
1
answer

Working with group_concat

I have some questions regarding the use of group_concat , more specifically performance. When using group_concat you can not use limit . // a query retorna todos os ID's select group_concat( id ) from table limit 5 // pelo...
asked by 18.08.2015 / 00:53
1
answer

write json file in the database

Is it a good idea? I was thinking of doing a project where the user will create several elements dynamically (tables, choose a certain option, fill etc), these dynamically generated elements should be saved in the database to be updated, modi...
asked by 05.08.2015 / 02:27