Questions tagged as 'sql'

1
answer

Add result of another sum

I'm trying to make a sum of the result of another operation. Below is the code I'm trying to do select distinct (SELECT(SUM(CAST(ROUND(ppre.Valor_Custo, 2) as decimal(18,2))) )) * (select isnull(sum(case when e.Quantidade &...
asked by 19.09.2018 / 15:24
1
answer

Update Query with select for Procedure

I'm trying to do a query that will enter a procedure but I'm not having success, the query looks like this: UPDATE sca_lotacao AS t0 SET t0.ativo = 0 WHERE ( SELECT * FROM sca_pessoa AS t1 RIGHT JOIN sca_lotacao A...
asked by 08.12.2014 / 19:03
0
answers

Deadlock with SQL SERVER PROCEDURE

I need to generate a game table for four groups with 5 teams, for each day a total of games must be performed, at the time the PROCEDURE that performs the insertion starts is called the bank goes in loop, someone knows where is the error?...
asked by 18.09.2018 / 00:44
0
answers

Difficulty with JPA annotations for entity relationships

I have the following relationships: CategoriaPeca , SubcategoriaPeca and Peca . A CategoryPart can have several SubcategoryPart , and a SubcategoryPart can have several CategoryPart , a part can only be in one SubcategoryPeca and onl...
asked by 06.09.2018 / 14:37
1
answer

How to delete primary key (PK) in MySQL?

I have the following table in MySQL: The id column is the primary key. I would like to remove the primary key from this table. How can I do this? Thank you.     
asked by 30.11.2018 / 04:56
1
answer

Different conditions of the same column

I have a table named anuncios : id | nome | finalizar | datafim 1 | teste1 | N | 0000-00-00 2 | teste2 | S | 2018-12-05 I would like to make a SELECT listing only the records where the value of the finali...
asked by 02.12.2018 / 01:46
1
answer

Select with subquery to pick up previous record

I have a structure of records of user readings by reference. According to data below. SELECT L.LeituraID, L.UsuarioID, L.Referencia, L.Leitura FROM Leituras AS L |-----------|-----------|------------|---------| | LeituraID | UsuarioID | Refe...
asked by 21.11.2018 / 18:28
2
answers

How to open a report file in RDF format?

I was sent a report with the .rdf extension. The system that generated this report uses MS SQL Server 2008 as the DBMS. I would like to know how to view and manipulate the information in this file.     
asked by 29.01.2014 / 20:36
1
answer

List users' phones from a join without duplicating the rows

Good evening, Well, I have the following problem: I need to join in two tables, USER and CONTACT. Each user has more than one contact (Phone), so when I 'm ready the data it returns me "duplicate" lines with different phones because, EX:...
asked by 03.01.2019 / 03:25
1
answer

How to pass an SQL expression to an UPDATE by Zend?

My MySQL DBMS has a table called elements where one of the fields is called posicao and is of type int (6) . I need to perform an update (SQL) where the posicao field should be updated with its own value subtracting 1 acco...
asked by 14.03.2014 / 23:20