Questions tagged as 'sql'

1
answer

Add subquery values separately

I have a problem with this query below: select sum(tb1.l1) * 0.3, sum(tb2.l2) * 0.3 from ( select setor, total_geral as l1 from mobile.auditoria where month(data) = month(now()) and year(data) =...
asked by 18.10.2018 / 16:37
1
answer

Error trying to import .bak file from Sql Server on Linux

I am very new to SQL Server and am trying to import a .bak file from a backup that came from another server (Windows) on Linux (Linux mint 19) The command I used on the terminal was this : sqlcmd -S localhost -U SA -Q "RESTORE DATABASE [de...
asked by 25.12.2018 / 16:09
1
answer

Bring the sum of IDS and data into two tables using SQL

I need to make an SQL to swallow me the data of: 'DATA | QTDE IDTa | QTDE IDTb | VALORa | VALORb | Saldo (diferença de VALORa - VALORb) ' But I am not able to bring the data correctly with this SQL example: link I need to get out like...
asked by 17.10.2018 / 20:41
1
answer

NodeJs query in SQL Server

Hello everyone, I need to do a filtered query for days in SQL in a NodejS application, but during the POST that is when I make the NodeJs filter I am accused of a value conversion error. When I run get get myself to retrieve the values of the Dat...
asked by 21.09.2018 / 17:17
1
answer

Left Outer Join Pulling Only Contained Data

I'm trying to do this research to know how many children and pregnant women each visitor attends but is only pulling the families that have pregnant even putting the blessed LEFT OUTER JOIN , is because of the ON clause? I can not...
asked by 04.10.2018 / 16:54
1
answer

Count and group by day

SELECT loc.loc_pac as registro, datediff(dd, pac.pac_nasc, getdate()) as 'dias' from loc with (nolock), pac with (nolock), str with (nolock) where loc.loc_pac <> '' and (loc.loc_pac = pac.pac_reg) and (loc.loc_str = str.str_cod) order...
asked by 29.06.2018 / 02:27
1
answer

Assign execute command to a variable

I need the return of the execute command to be assigned to variable @PAGO because I will insert it into a temporary table only what returns is the script, not the value. DECLARE @COMANDO_COMANDO_PAGO VARCHAR(2000) SET @SITUACAO = 'PAGO'...
asked by 12.10.2014 / 19:59
2
answers

How to put between inside a query in code?

I have the following query and would like to put in the Where clause the condition of being within a certain period. public static DataTable stCloseCaseAll(int schoolId, string dataInicial, string datafinal) { var sb = new StringBui...
asked by 15.05.2014 / 19:41
1
answer

Deletion involving Java and SQL

The program I'm doing needs to delete users from the database! In the code I determine: Menu: static private void Excluir(Connection con) throws SQLException { String cpf; Scanner s = new Scanner(System.in); Cliente cli = new C...
asked by 26.05.2014 / 14:28
1
answer

Extract xml tag from a varchar (max)

Hello, I have a series of xml records in a varchar (max) column and I need to extract the <MT_USADA>16 MB</MT_USADA> tag, for example: <?xml version="1.0" encoding="utf-8"?> <consulta xmlns:xsd="http://www.w3.org...
asked by 26.06.2018 / 22:04