Questions tagged as 'query'

0
answers

How to find in SQL what is the primary key of the table?

I'm learning SQL, and I ran into the following problem: I need to know which of the columns is the primary key of the table. Is there a command I can use in SELECT to get a return this information? I've already seen the topic: # It d...
asked by 01.02.2018 / 00:22
1
answer

Error converting date and time Query SQL Server

Well, I'm trying to run the query below, however, the following error is occurring. "Failed to convert string date and / or time.". I have already done some other conversions, but without success. select MesID,Mes,Ano, cast(SUM(DateDiff(MI...
asked by 29.01.2018 / 18:46
1
answer

Create query to return the lowest possible value

Good evening. I need to do a sales report grouped by period and by card. But I do not know how I can enter a store and horizontally it appears the values of each card. Example of what the output should look like: Loja01, with 03 sales (100 visa,...
asked by 05.02.2018 / 23:49
1
answer

Error executing script

I'm trying to run the query below, but the following error occurs. "Converting a varchar data type to a datetime data type resulted in a value out of range." select MesID,Mes,Ano, convert(time,dateadd(second,SUM ( DATEPART(hh,(convert(...
asked by 30.01.2018 / 16:29
1
answer

Error executing SUM - SQL Server

Well, I'm trying to do SUM according to the query below, however, the following error occurs. "You can not perform an aggregate function on an expression that contains an aggregation or a subquery." The output is to exit this way. Total_Horas...
asked by 24.01.2018 / 13:27
0
answers

How can I not freeze / crash the application when querying data via SQL Server and creating a "progress bar"?

The code below as an example brings me great information from the database. Every time I click on the "Search" option of my program, my application freezes / hangs for a while until the select "pull" everything. I would like to know how best to...
asked by 22.01.2018 / 13:58
0
answers

Query - SQL Server with stuff

Please, in the query below I want you to bring it as follows. contato andreia, marcos, juliana ie on the same line. In the query, I used stuff , but to no avail. Today she's bringing it that way. contato andreia marcos juliana...
asked by 23.01.2018 / 16:11
1
answer

Check codes that are not in the database with a query

I know that I can check codes that are in one table and are not in another with the following query : SELECT cod FROM tabela1 WHERE cod NOT IN (SELECT cod FROM tabela2) But how can I check the records that are not in a table but are in a c...
asked by 26.01.2018 / 14:54
1
answer

Grouping and adding in a query in SQL Server

Good afternoon, I have the following problem: I'm developing a C # program to query internal company data. It's working perfectly, but I need to group field (s) and add other value (s). Query(C#+MSSQL):SqlCommandmyCommand=newSqlCommand...
asked by 04.01.2018 / 13:27
1
answer

SQLQuery - Some Duplicate Records

Galera, in the query below is bringing as follows. UsuID Consultor Tentativa 1 Abertos 95093 Gabriela 96 However, it is meant to bring the following: UsuID Consultor Tentativa 2 Abertos 95093 Gabriela 48...
asked by 08.01.2018 / 18:27