Questions tagged as 'sql'

2
answers

Select too slow, how to improve?

I have a cadre of craftsmen with about 90 thousand records. I created the SQL below to return me the total of artisans in each of the regions that they are registered. Although it works, it is slow, taking more than 30 seconds to return the reco...
asked by 22.09.2016 / 19:52
1
answer

Mark duplicate fields in a table

I have a table in my database and would like to mark occurrences where certain code repeats itself. Remember that this code field is not a primary key. Example: Data Código Repetição Status ... 25/2/2014 138863 ok...
asked by 12.03.2014 / 21:07
1
answer

Unwanted Result - SQL Query

Hello. I'm a problem and I can not see a way to solve it. My data from the move table: Myquery:selectavg(m.valor)fromMovimentacaomwherem.tipo='SAIDA'groupbym.data;Myresult: I can not group the average by date (day). Even if I use d...
asked by 04.09.2018 / 02:30
3
answers

How to perform a select by multiple fk?

I have a question about one (or more) select . I have the following bank set up and I need to do a search for a particular recipe based on one (or more, and oh, that's the problem) ingredients. How do I get the recipe that contains all the...
asked by 23.03.2018 / 04:55
2
answers

Add or subtract value, depending on the type of posting (MSSQL)

I have the following query: SELECT MOVTIPOPRODUTO.ID_ENTIDADE, ENTIDADE.NOMECLIENTE, PRODUTO.NOMEPRODUTO, TIPOPRODUTO.DESCRICAO, MOVTIPOPRODUTO.ID_PRODUTO, MOVTIPOPRODUTO.ID_TIPOPRODUTO, MOVTIPOPRODUTO.ID_SAFRA, MOVTIPOPRODUTO.ID_LOCALE...
asked by 23.07.2018 / 14:27
2
answers

Include strings in BETWEEN and List missing values in SQL query

Next. Imagine that I have in the bank in the field of paid months the following launches: 2015-03, 2015-04, 2015-7, 2015-9. If we stipulated a period for example: from 2015-02 until today (2015-9). What months are missing, ie, which months have...
asked by 24.09.2015 / 14:50
1
answer

How to set up a field using three others?

I have the following fields in the database: | id| estados | cidades | categoria | todosjuntos | | 1 | mg | sao paul| informati | mg/saopaulo/informati | The first 4 are populated, but I would like to insert in the todosju...
asked by 10.10.2014 / 23:25
1
answer

Discover the numbers that least appear in the records

Personal greetings. I have a table something like this: reg num0 num1 num2 num3 num4 num4 1 4 2 5 8 10 15 2 3 7 8 15 20 21 3 14 10 6 21 17 1 4 1 4 8 10 16 7 5 9 3...
asked by 12.11.2015 / 04:24
3
answers

Is there a way to start a Select (SQL) in the middle of the data table?

Is there any way in the SQL language (and using BD mysql) where I can start a Select in the middle of a table? For example, I have 500 addresses in the table. I search the addresses of Bairro X (where neighborhood="x"), reducing the total to,...
asked by 19.12.2017 / 16:35
3
answers

Do not repeat records in a join

I have two tables: One with 1009 records and another with 11949. When I do a join, I have 11949 records, and the records in the 1009 records table are repeated several times. I need to do a select with join, but bring only the amount of records...
asked by 20.04.2017 / 22:19