Questions tagged as 'sql'

1
answer

Get table name with Trigger / Function in Postgres

I am implementing a simple replication form of two tables or more. I have the replication table that has the name of the table to be replicated and id. To feed the replication table I have a trigger on each table that will be replicated b...
asked by 11.01.2018 / 18:27
1
answer

Calculate average length of service

Well, I need to take the average number of calls and I have the following data: 00:12:35 00:05:10 00:01:42 00:08:12 00:01:01 {...} The question is, how can I do it? I searched for a way to do this using Mysql's AVG but I did not succeed ......
asked by 17.01.2018 / 19:37
1
answer

Difference between days and minutes on Sql Server?

I have two columns of type datetime . I have tried in many ways to get the difference between them, but the number of days always goes incorrect. Example: Data1: 2018-01-17 17:00:00 Data2: 2018-01-18 10:00:00 Resultado obtido: 01 17...
asked by 18.01.2018 / 01:37
1
answer

Performing UPDATE in ORACLE using FROM

How to UPDATE in Oracle records without using a IN clause to change bulk data? This way: UPDATE TABELA1 SET DADO = DADO FROM TABELA2 WHERE TABELA1.CODIGO = TABELA2.CODIGO; Currently it forces me to report a IN c...
asked by 12.01.2018 / 21:15
1
answer

How do I write the following SQL code in the Codeigniter Model?

select count(situacao) as Qtde, sum(valorcausa) as Total_Valor_Causa from processo where situacao = "Tramitando";     
asked by 23.04.2018 / 22:58
1
answer

Difference between linking tables with WHERE and with INNER JOIN

I was learning SQL and came across the following instructions: SELECT tbl_Livros.Nome_Livro, tbl_Livros.ISBN_Livro, tbl_Autores.Nome_Autor FROM tbl_Livros, tbl_Autores WHERE tbl_Livros.AutorID_Livro = tbl_Autores.ID_Autor; An...
asked by 21.12.2017 / 18:21
3
answers

Relationship between tables varying according to value

I have a table that can write id fence (FK) in more than one column. I need to make a select that links to the first reference column and if it is null, make the link through the second column. My query: SELECT * FROM nfs n , nfs_it...
asked by 21.12.2017 / 19:56
1
answer

Make the current value subtract from the previous value

I'm trying to make a supply system, I need it to take the last km registered in the bank of a specific vehicle and be subtracted by the new one that will be inserted I'm trying to do this, but it does not show any error, but does not subtract ....
asked by 11.12.2017 / 20:39
1
answer

Problem saving

Only one form that is returning this error, the question I do not know what can be or how to do it, some ask to put the relationship in cascade what is already.   NHibernate.TransientObjectException: object references an unsaved transient ins...
asked by 28.02.2018 / 18:55
1
answer

Problem in Query Builder Laravel

I am in doubt about a query with joins in my project, when running Select directly in the database I have no problems, but when building with Query Builder, I do not get results. Where would he be missing out on her set up? Normal Query:...
asked by 04.01.2018 / 01:34