Posts by Marta B • 269 points
12 posts
-
0
votes1
answer37
viewsA: Query returns another user’s value
In the where probably missing parentheses around clause OR. WHERE aw.codigoprofissionalcontratado = :codigo AND aw.databaixa IS NULL AND (datapagamento IS NOT NULL OR valortaxa = 0)…
-
0
votes2
answers663
viewsA: Left Join or Sub-Select? which one has the best performance?
Have you tried a solution of this kind: select a.numeroOp as OP, a.codigo as CÓDIGO, (a.qntAhProduzir + a.qntParaEstoque) as QNT, (CONVERT(varchar(100), a.numeroProjeto) + '_' +…
-
1
votes1
answer4475
viewsA: Mysql error : #1265 - Truncated data for 'value' column in row 1
Only one stitch should be used when necessary. There is also no need to use. If the value to update is 2400, you can stay only: UPDATE procedimentos SET valor = 2400 WHERE procedimentos.id_proced =…
-
2
votes1
answer878
viewsA: Delete SQL record with dependency
When creating the foreign key it is possible to define its behavior when there is a DELETE: NO ACTION: Delete parent record is not allowed. An error message is generated. CASCADE: The entire line of…
-
0
votes1
answer264
viewsA: Constraint in a key Primary - SQL
Creation of the table primary key CustomerAddress: CONSTRAINT PK_CustomerAddress PRIMARY KEY (IdCustomer, CdAddressType) Creation of 2 foreign keys: CONSTRAINT FK_IdCustomer FOREIGN KEY (IdCustomer)…
-
2
votes3
answers5873
viewsA: Remove repeated lines in all aspects on Oracle
In sql server, the method below works. In oracle I think it is similar: select * into #table from( select nome = 'JOAO', id=1234, email='[email protected]', sexo='m' union all select nome = 'JOAO',…
-
0
votes1
answer425
viewsA: How to calculate the year from the number of days?
int ano = 0 while dias > 0 { if ano == bissexto then dias = dias-366 else dias = dias-365 ano++ } return ano
-
0
votes3
answers996
views -
1
votes3
answers645
viewsA: SQL Server subquery is always returning null. How to fix.
When the complement column of the table, has the value NULL in a row, so that it is returned by the query it is not enough to do: [...] where complemento = @complemento [...] NULL values cannot be…
-
2
votes1
answer117
viewsA: How to fill null with previous row value?
Whereas the rows are ordered by the header column 1, and this column is numerical and sequential (no holes in the numbering): select cabecalho1, cabecalho2, novoresultado = isnull(cabecalho2,(select…
-
2
votes2
answers957
viewsA: How to compare set of numbers with other set?
Although I doubt whether performance will improve, another way to compare records is by using INTERSECT. Example: declare @conjunto int, @conjMin int select @conjunto = max(conjunto), @conjMin =…
-
3
votes1
answer375
views