Questions tagged as 'sql-server'

2
answers

Bring records from today's date up to 1 month ago SQLSERVER

How do I get records for today's date up to 1 month ago in SQLSERVER? I know that for example, with 7 days, I use GETDATE () - 7. But for 1 month, what would it look like?     
asked by 07.11.2018 / 14:21
1
answer

How to create a function in python to connect the sql server?

To summarize the connection process, I'm trying to create a function to connect the database, but I'm not able to make the connection as expected: def conectar_com_banco(usuario): if usuario in 'illuminati': username = 'illuminati'...
asked by 30.11.2018 / 18:37
1
answer

Select from column B if the field selected in column A is null

In a SQL query I was trying to work out a way to select a value from another B column if the selected A column is null . At first I made the following query: SELECT COALESCE(NULLIF(max(convert(smalldatetime,DEP.DATAENTRADA,100)),null), DE...
asked by 25.10.2018 / 20:01
1
answer

Getting information from a JSON and saving in SQL Server using JavaScript

I have this code, which returns the information I want and shows on the page. Now I would need to save this information in a SQL Server database, how would that be possible? It's been really hard for me since I've never worked with API, JS...
asked by 22.10.2018 / 23:40
1
answer

Replace SQL SERVER between columns

How to do a replace between columns in SQL SERVER. For example, given the table below: COLUNA_A | COLUNA B | COLUNA_C A 123 casa I tried to run the query: SELECT REPLACE(COLUNA_C, COLUNA_A, COLUNA_B ) FROM TABELA To try...
asked by 09.12.2018 / 14:24
1
answer

SQL - Query Logic

I am breaking my head with a situation I want to bring a return of a query considering only useful days. This table has a list of users: Thistableispopulatedbyusers: Iwantthequerytoreturnthedaysnotfilledbytheusers,disregardingSaturdaysand...
asked by 22.09.2018 / 09:25
1
answer

How to add another column to my query that is in another table

SELECT DEPARTMENT_ID ,(SELECT DEPARTMENT_NAME FROM HR.DEPARTMENTS) AS 'Nome do Departamento' ,MIN(SALARY) AS 'salario minimo' ,MAX(SALARY) AS 'salario maximo' ,CAST(AVG(SALARY) AS NUMERIC(8,2)) AS 'salario medio' FROM [HR].[EMPLO...
asked by 20.10.2018 / 19:57
1
answer

Connect columns from different tables

SELECT e.EMPLOYEE_ID AS 'ID' ,e.FIRST_NAME + ',' + e.LAST_NAME AS 'Name' ,(SELECT DEPARTMENT_NAME FROM HR.DEPARTMENTS WHERE HR.EMPLOYEES.DEPARTMENT_ID = DEPARTMENT_ID) AS 'Department Name' ,e.SALARY AS 'Base Salary' FROM [HR].[EMPLOY...
asked by 21.10.2018 / 19:09
2
answers

Search for unformatted sqlserver data with select

I have a field in the table Clientes with name CPFCNPJ but its data is formatted with points and hyphens and would like to do a SELECT in> formatting this data without punctuation. Is it possible to perform this type of sea...
asked by 06.09.2018 / 06:42
1
answer

View most current record sql server 2008

I am trying to fetch only the last record (last sale) from each client and I am not succeeding. I've tried it in many ways, but nothing .. Just returns all sales from the date. Follow my query. Thanks for the help. use banco select m.cli_forn,...
asked by 19.09.2018 / 21:45