Questions tagged as 'sql'

1
answer

Select best sellers in related table

I have a table pedidos , produtos and other produtos_em_pedidos described as follows: produtos: id | nome pedidos: id | data produtos_em_pedidos: produto_id | pedido_id | quantidade I need to select the products that mos...
asked by 15.03.2017 / 14:43
0
answers

MS SQL Query for JSP

I'm creating a website based on the JSP language but I do not know how to return a query that I performed on MSSQL Server , it looks like this: DECLARE @Nomes VARCHAR(8000) SELECT @Nomes = COALESCE(@Nomes + ', ', '') + nome FROM usuarios W...
asked by 08.03.2017 / 14:48
1
answer

How to perform the sum of values that I have multiplied?

I performed an operation that multiplies the quantity of values by the unit value of each one, obtaining the total value per product. How could you add up the total values of all products? I tried with a Sum inside a Sum ... EDIT1: I tried to...
asked by 20.04.2017 / 19:39
0
answers

Normalize database (unpivot columns per month)

Good evening, An Excel table with PERVASIVE SQL binding with one column per month, that is, 12 columns. In order to better work the data, I need to turn the 12 columns into only 2:  - a 1st with the values that were in the 12 columns  - a sec...
asked by 28.03.2017 / 22:29
1
answer

Verifying that the database column value contains only numbers in the select

I need to find out if the value of a given column of the database contains only numbers in the select itself, because if it is numeric, I need to display the value of another column. I use an ORACLE database. Can anyone help me with this p...
asked by 30.03.2017 / 19:55
0
answers

Understanding sysprocesses

I'm using the sys.sysprocesses table in SQL 2012/2014 , to identify through the CONTEXT_INFO field, which user of a certain application is bound to a particular session. I created a function by passing% as_with%. CREATE...
asked by 22.02.2017 / 13:42
0
answers

Return value DataLayer [closed]

Good afternoon. I have a procedure that does some commands and returns 0 = success; 1 = unsuccessful; alter PROCEDURE [dbo].TesteRetorno ( @DS_NOME_ARQUIVO_SINCRONISMO AS VARCHAR(200) = null ) AS if exists(select...
asked by 27.07.2017 / 18:57
0
answers

How to join 3 queries of different record amounts?

I need to merge 3 queries with results and quantities of different records into a single query, using the Where end of the script as where for all queries . How can I do this? I have tried Union , but it does not run, displaying error...
asked by 17.02.2017 / 15:46
1
answer

Doubt in creation of Table

Good Night, I am creating a database for an association, where it is necessary to do the renewal every semester. I created a registration table with the data of the partners: create table Cadastrados( Nome varchar(50), Matricula varchar(9) uni...
asked by 23.03.2017 / 00:27
2
answers

How would the query return values in a given interval?

I have a table with the following rows : code (int) vaccine (varchar) dt_volution (datetime) I need a query to return all vaccines that will expire within 10 days, counting today's date. I tried something like this that I saw i...
asked by 23.01.2017 / 16:58