Questions tagged as 'sql'

5
answers

Subtract sums of fields in two distinct tables

I need to add the value of a column in SQL, so it looks like this: SELECT SUM(qtdsaco) FROM armazem This code works. Now I need to add the value of the other table, it looks like this: SELECT SUM(qtdsaco) FROM armazem2 So I had to take...
asked by 24.08.2016 / 21:37
1
answer

What kind should I use to save only the (undated) time in a database?

I'm in doubt on what kind I should use to work with hours on my system. Should I use DateTime , Time or TimeStamp . I wish the times were saved in this format: HH:MM     
asked by 09.07.2015 / 18:43
3
answers

What is the purpose of the MINUS command in oracle?

I've never seen this command before and I also do not find it around here, I do not know if it has a different name and because of the Oracle documentation, I can not understand exactly how it works. I just want an explanation and a simple examp...
asked by 12.06.2015 / 20:12
1
answer

Improve the performance of a query

How could I improve this query, which returns me the top 10 sales to assemble a chart, so that it processes faster? set @startDate :='2015-01-03'; set @endDate :='2015-05-31'; set @dst_id:=1; SELECT SUM(vnd_quantidade) as quantidade, (S...
asked by 29.06.2015 / 14:25
5
answers

How do I list all the tables with their respective banks?

I would like to list all the tables in my database that end with a specific name and also all my databases that match those tables. I tried to do but it does not return anything to me. Query SELECT da.name AS BANCOS,ta.name as TABELAS FROM...
asked by 05.06.2017 / 14:51
3
answers

Calculate difference between Dates in SQL Server, with Years, Months, and Days output

What would be the SQL (SQLSERVER) that could extract the difference between two dates (the largest being the current system date) with Years, Months, and Days output?     
asked by 29.06.2014 / 18:08
2
answers

SQL SERVER - Convert String in Days

How can I convert this string into days? Example: return "2 days and 2 hours"? SELECT '50:00:00'     
asked by 20.07.2018 / 20:53
2
answers

SQL - UPDATE double with double where

Next, is it possible to do two update-where together in the same query? I'll explain, what I wanted to do is this: UPDATE usuarios SET nome = "Matheus Silva" WHERE id = 1 AND UPDATE usuarios SET nome = "Lucas Silva" WHERE id = 2...
asked by 18.01.2016 / 05:06
2
answers

Clause similar to MySQL's LIMIT in MSSQL

I need to run the query below in PHP with SQL Server, however I can not use the LIMIT clause missing in Microsoft queries . $SqlTabelaAtual="SELECT * FROM BusinessCadTabPreco RIGHT JOIN BusinessCadTabPrecoItem ON B...
asked by 15.01.2016 / 15:17
2
answers

select from date in the postgreSQL database

How do I make a select in the postgreSQL database for it returns the data from a specific date, for example I have a field of type timestamp with name data_interview, I want it to bring me the data registered from the present day forward . SEL...
asked by 19.10.2016 / 18:46