Questions tagged as 'sql'

3
answers

SUBSELECT vs. INNER JOIN

Is there any recommendation on which of the two is preferable in terms of performance? SELECT funcionarios.nome FROM funcionarios INNER JOIN empresas ON empresas.id = funcionarios.empresa_id WHERE empresas.nome = 'Nome da Empresa' or SE...
asked by 30.06.2014 / 13:35
1
answer

Error in SQL query

Hello, I have a table in the database that has several times stored in it. And I'm just making an appointment that is giving error. Inquiry: select proximo from (select localizacao.horario as proximo from localizacao where localizacao.horar...
asked by 01.10.2018 / 13:12
1
answer

calculating date in mysql update

Well I need to update my accounts that are over 5 months old, I wanted to do this right in mysql. The update looks like this: UPDATE contas SET baixa_valivade = true WHERE data_vencimento (Preciso verificar se já esta vencida a mais de 5 meses...
asked by 26.09.2018 / 18:16
1
answer

Using Case or if

I am a beginner in SQL and am having difficulty using CASE WHEN . I have a table called CRM_PROCESSO , in which there is a column with the Status option, but the answer for this status is numeric, being 1 - Aberto ,...
asked by 12.09.2018 / 14:16
1
answer

Copy records from one table to another via select

I am copying the records from one table to another on different banks, however a column in the new table can not be null and the data coming from the old table is null. Is there a way to put some conditional so that it "turns" null fields into s...
asked by 06.08.2018 / 20:29
2
answers

In a SQL query, to bring row values in a single row, in the field

I need to make a query that brings values of 2 rows into a single Ex: id | valor | banco 000001 | 1000,00 | caixa 000001 | 1000,00 | bradesco I need it to look like this: id | valor | banco 1 | banco 2 000001 | 1000,00...
asked by 02.08.2018 / 21:45
1
answer

Insert two commands (INSERT and UPDATE) into the same statement in SQLite via R Language

Hello, people I have a problem with how to insert two commands (INSERT and UPDATE) into the same SQLite statement via the R language. I do not know if this is impossible because of SQLite or the DBI package of R. Here is an example of w...
asked by 26.07.2018 / 20:20
2
answers

SQL helps to join 2 selects

I have 2 selects below, how can I join in just 1 select? I need to get everything sold in a certain period (BETWEEN) per item only at the same time I have to get what I had from the item's stock up to the start date. To separate whether it...
asked by 01.08.2018 / 23:01
2
answers

Query SQL condition if

I have a problem in doing a query where I have 3 fields and only one of them is filled up that no longer shows this result. Can someone help me do this? select * from tabelas where campo1 and campo2 and campo3     
asked by 30.05.2014 / 17:24
3
answers

Place a hyphen when the value is 0 in select

How can I do in% with a mysql (SELECT) so that when the value is equal to query , replace it with 0 . Value field: int.     
asked by 21.02.2017 / 17:50