Questions tagged as 'sql'

3
answers

Error in sql server

In sql how do I make a select with space and no spaces? That is, when I have a pass of the genre '123456' and '123456', the last one with space happens that if I do in the query and I have '123456' in the bd I should not show any field that h...
asked by 24.09.2015 / 19:02
2
answers

Select all references to the given table (foreign key)

I need a way to select all the foreign key of a particular pk . In other words, I want to get a particular primary key and select all the foreign keys that "point" to it. Preferably I want to get the name of the column that has the k...
asked by 08.10.2015 / 15:51
2
answers

Problem with SQL relational logic

Considering this scheme CREATE TABLE bra_ocorrencias ( estado varchar2(2), genero varchar2(1), ano number, nome varchar2(30), num_ocorrencia number ); I need to make a query that returns me the most registered name for w...
asked by 06.07.2018 / 16:29
1
answer

Insert with two different selects

My insert is not working. insert into t_cmo_oit1980 (id_oit, id_exm_rea) select max(id_oit) + 1 from t_cmo_oit1980, select id_exm_rea from t_cmo_Exame_Realizado where id_exm = 3936 and id_xfc = 39517; go I made a gambi a...
asked by 18.04.2017 / 21:46
2
answers

Compare items from different tables

I have two tables: Pessoa1 Pessoa2 +----+--------+ +----+--------+ | Id | Nome | | Id | Nome | +----+--------+ +----+--------+ | 1 | Maria | | 3 | Maria | | 2 | João...
asked by 08.09.2015 / 22:44
2
answers

Log table using MySQL

How to create a MySQL audit log table that stores when and what was changed in each record? Does MySQL provide something that can make this kind of thing easier?     
asked by 02.09.2015 / 14:56
2
answers

Dapper requires writing SQL code, why?

I'm looking at the following link using Dapper: Getting Started With PostgreSQL Using Dapper In .NET Core and my question is, when I do it through Java I do not need to write the SQL code as this example here: //1. Insert using (var conn =...
asked by 17.08.2018 / 22:06
2
answers

How to use the WHERE clause over a column made from row_number () over ()

I am trying to use the where on top of a column generated by row_number but it does not work; is it possible to do this?     
asked by 23.09.2018 / 00:48
4
answers

Select from previous months

I need to select in data from previous months, month by month. My query looks like this: SELECT * FROM VIEW_INCD WHERE MONTH(DH_CRIA_INCD) = DATEPART(mm,GETDATE()) - 1 AND YEAR(DH_CRIA_INCD) = YEAR(GETDATE()); Okay, I select only t...
asked by 08.08.2018 / 15:19
1
answer

I need to return the null values of this inner join

I have this select of MySQL: SELECT credor.nome, banco.descricao FROM credor INNER JOIN banco ON (credor.banco = banco.codigo) It returns me all the lenders and their respective bank, but if the bank of the guy is NULL it just does not ret...
asked by 10.11.2015 / 20:00