Questions tagged as 'sql'

2
answers

Why is not a good OR in a LEFT JOIN?

I am creating a query and my pull request returned because the code tester considered that OR is not good for table relationships. Example: FROM LEFT JOIN administracao.cidade cid ON (cid.cid_cd_cidade = cec.cec_c...
asked by 25.04.2018 / 15:48
1
answer

PostgreSQL Percentage

I can not perform the percentage of this query. You should take the sum of the "value_convenio" of each municipality and divide by the sum total of the "value_convenio" : <h3>Entrada SQL SEM CALCULO DE PORCENTAGEM</h3> SELECT...
asked by 09.04.2018 / 20:48
1
answer

How to do a "select like" to a result of a subquery

I need to make a select in sql server 2014 to the result of a subquery, example: select * from tabela2 where codigo like ("1;3;4","3","1;2;5") Where ( "1;3;4","3","1;2;5" ) is the result of the subquery ( sele...
asked by 27.09.2017 / 17:06
1
answer

Update on two SQL Server tables [duplicate]

How do I perform an update at the same time on two different tables? I have a table named Tarefa and another called VinculoReferencia , both have the field Taridinclusao where is this field that needs to be updated at th...
asked by 02.10.2017 / 22:56
1
answer

How to assign the value of a variable that is in a JavaScript function to an SQL query.

I have a javascript function that gets the value of the selected item in a combobox, and would like to pass that value as a parameter to a SQL query to bring the data that are related to the value obtained in the selected combobox in my asp page...
asked by 24.04.2014 / 19:37
1
answer

JOB with 2 steps, first step stops when it reaches 1 minute of execution

I have a JOB configured in SQL to run every 30 minutes, it has 2 steps, 1 procedure in each step, but when the first step reaches 1 minute of execution, it quits without executing all the registers it should and starts the second step. How do...
asked by 30.10.2017 / 12:15
1
answer

Sort by month without repeating the year

I would like to add up the total sales in the month, but not repeat the year. select EXTRACT(year FROM v.dataVenda), case when EXTRACT(MONTH FROM v.dataVenda) =1 then sum(v.valorvenda) else 0 end as Jan, case when EXTRACT(MONTH FROM v.dataVend...
asked by 22.08.2018 / 15:02
1
answer

Calculating SQL hours

I need to implement a working hours report within a period. My difficulty is this: the records for each day are on different lines and because of this, I'm having a hard time knocking in and out of the right days and I still have to subtract...
asked by 14.09.2018 / 23:22
1
answer

Select Electronic Point Record (SQL)

How can I collect only the first and last mark, where an official can have X Markings and even markings the next day? As the example below +------+--------+-------+-------+ | FUNC | DATA |ENTRADA| SAIDA | +------+--------+-------+-------+...
asked by 01.09.2018 / 21:35
1
answer

I need to add values from a table

I have a SELECT and in it I display the sum of the sales values of each product, would I have to make a total sum of the table that made the sum? SELECT cadpro.descricao, sum(itensped.total_venda) AS total_venda FROM itenspe...
asked by 08.12.2017 / 13:59