Questions tagged as 'sql'

1
answer

Sort results with month and year

I have a table with the mes E ano fields. How can I sort results by month? I am already ordering by the year = > SELECT * FROM tabela WHERE id_cliente = '$id_cliente' ORDER BY ano DESC Now how can I order the months too...
asked by 11.07.2017 / 15:44
4
answers

sql - SELECT for recent data only

   I think my title is not a question. The application I develop inserts data pertaining to the last backup into a table once a month. This table contains the backup instance code, the given insert and the number of bytes. The problem is...
asked by 05.02.2015 / 15:55
2
answers

Finding a value in several fields

In my bank I have 3 columns for phone, I need to know if the value is in any of the 3 fields, what is the best way to assemble this select?     
asked by 07.01.2015 / 20:52
3
answers

Adding result values in mysql

I'm servicing a bank and I'm having trouble making a select . Structure of table descontos_taxas : id | value | customer | data_created My Scenario: This table stores both fees and discounts in the same table. The rates are posit...
asked by 14.05.2014 / 22:40
3
answers

How to show quantity of sales per form of payment per month in SQL Server

I'm having the following result: Mes | QtdPorMes 1 | 124 2 | 102 3 | 84 4 | 32 I would need it to look like this: Mes | Boleto | Cartão | Total 1 | 100 | 24 | 124 2 | 82 | 20 | 82...
asked by 10.04.2018 / 15:47
3
answers

Do not return value of a field, when it is zero

I am creating a query in SQL , but I need a field not to display the values when it is zero. Is it possible? SELECT gfilial.nomefantasia AS 'Filial', tmov.codtmv AS 'CODTMOV', tmov.numeromov AS 'Número', tmov.valo...
asked by 10.07.2017 / 20:19
2
answers

How to force a drop table in SQL?

When trying to give a drop table in a table that has relationships, the following error occurs: #1451 - Não pode apagar uma linha pai: uma restrição de chave estrangeira falhou    Is there any way to force deletion of the table...
asked by 18.05.2017 / 13:58
1
answer

Concatenate results

How to concatenate all results of a query in SQL Server in order to return all information in a variable? For example, considering a cliente table with the following composition: ╔═══╦════════════╗ ║ ║ Nome ║ ╠═══╬════...
asked by 11.05.2017 / 19:49
1
answer

How to calculate the average using conditions in SQL Server?

The question asks me to show the number of students with averages greater than 7, less than 7 or equal to 7 for some tables that I have here. Showing this way: How to create this column of Description ?     
asked by 01.09.2017 / 16:33
5
answers

Select last dates for each month SQL

I would like to perform a SQL to get a list of dates on the last day of each month. Example: From a list of 01/01/2016 until 12/31/2016 return the last days of each month: 1/31/2016, 2/28/2016 ... 12/31/2016. The database is in FileMaker....
asked by 03.10.2017 / 21:52