Questions tagged as 'sql-server'

2
answers

How to get the sum of an entire column in SQLSERVER

I need to get the total value of the VOL field (image below), it is already generated by the SUM function. It can be in another query. All periodic tithe is required. ex: total = VOL (7.6890028) - > sum of the 4 lines of column VOL...
asked by 03.05.2018 / 21:56
1
answer

How to sort a date that is in varchar format?

I have the following select: SELECT a.nome, a.cidade, a.telefone, a.dt_criado FROM cadastro AS a GROUP BY a.nome, a.cidade, a.telefone, a.dt_criado HAVING COUNT(*) > 0 ORDER BY a.dt_criado DESC a.dt_create...
asked by 03.05.2018 / 21:43
3
answers

How to bring salespeople who did and did not make sales yesterday?

In this select I am bringing all the employees who accessed the application yesterday PO.DAT_COLETA and who performed yesterday PE.COD_PEDIDO . But I also want to bring those who accessed yesterday and did not make sales, today I do...
asked by 02.02.2017 / 13:01
2
answers

How to filter records by date using SQL

I am using SQL Server and need to query on a table the latest price record according to the date. Of all the records, I need him to bring me only 1 and with the current date. How do I do this?     
asked by 20.12.2018 / 13:58
2
answers

Doubt with group by for last record

I want to make a select that brings the data of note of each student, grouped by student and matter, but I want only the result of the last test of each matter. For example a student can take the English test 3 times, and math twice, in t...
asked by 12.12.2016 / 15:11
2
answers

How to use @ in SQL SERVER?

I need to retrieve the quantity of product with price between 0 and 10. There is an error in the @W_NUM variable of the select command. BEGIN TRANSACTION; DECLARE @W_P1 int; DECLARE @W_P2 int; DECLARE @W_NUM int; set @W_P1=0; SET @W_P2=10; SET...
asked by 24.11.2016 / 00:43
2
answers

Problem with IN condition in the sub-select

I have the following problem; I'm trying to do a search and include the value of the WHERE principal in a sub-select , however the result is always reported as 0, Part of the query I'm having difficulties is this: SELECT (...
asked by 21.11.2016 / 20:14
1
answer

Percentage calculation in SQL SERVER

I have a little question that I can not solve, I searched the community here, but I did not find exactly what I wanted. My situation resembles the following: I have N product records in my database. And in these N records, I have only 3 diffe...
asked by 08.03.2016 / 17:55
2
answers

Generate Inserts from an already populated table

I have a populated table and need to generate the scripts of insert of the data stored in it, I can not export, it must be script of insert into ...  Doing with select concatenating is very laborious, since I h...
asked by 12.09.2017 / 22:15
2
answers

Which database is ideal for my scenario?

I am developing a commercial automation system (C # and Windows Forms) that can be installed on one or more machines on the same local network. I've also done the mobile part of the system, where you can place requests through any device th...
asked by 31.05.2016 / 06:11