Questions tagged as 'sql'

2
answers

SQL Query, join 4 tables, 2 group_concats + conditionals, Help

Hello, I have created a query sql to return all client data in a single query, this query works partially if all conditionals are satisfied, but this system uses soft delete, in which all the records can not be deleted and only marked as inactive...
asked by 01.07.2015 / 14:27
1
answer

How to sum the values of a specific column with the sum () function?

I have the following command: select substr(b.chave, 28, 7) numeronf, upper(d.apelido) usuario, decode(b.loja,1,'Loja 1', 2,'CD', 3, 'Loja 2', 5,'Loja 3', 89, 'PANIF', 90, 'Restaurante' ) loja, c.nomerazao, a.data_inicial, a.data_final,...
asked by 11.02.2015 / 13:27
1
answer

Querying using between with sql server 2005

I am making a query using the Between operator to select a date range in the SQL Server 2005 database. Below are the data from the Servico table: linha1: 2015-02-04 14:51:01.577 linha2: 2015-02-04 14:51:02.137 linha3: 2015-02-04...
asked by 04.02.2015 / 18:17
1
answer

Select two tables and insert into two tables at the same time

I have four tables tabela A aic002 campos : codigo data nome especie valor rg cpf exped Tabela B excli campos codigo nome rg cpf exped tabela C imovel Campos codigo imovel rua bairro cidade estado tabela D escritura codigo data especi...
asked by 02.02.2015 / 23:04
1
answer

sql syntax error

I'm trying to do an insert in the database but I'm having a syntax problem, I still can not identify the error. $sql='INSERT INTO tabela ( nome, nit, rg, cpf, ) VALUES'; foreach($dados as $li...
asked by 09.03.2015 / 18:52
1
answer

How to get bank reports through web application?

Where I work there are some procedures in the database (SQL Server 2008) that take hours to execute and return large amounts of information that are always copied to a worksheet and sent to the end user. There are even some desktop applicatio...
asked by 23.01.2015 / 15:23
1
answer

How to view the SQL executed by php when using the "prepare ()" and "execute ()" functions?

Hello, I need to give an echo or print in the SQL executed from the function below. The goal is to visualize how SQL will look when the values of "?" replaced. Does anyone know how I can do this? public function insert (EmployeeTO $ employeeT...
asked by 04.01.2015 / 01:43
1
answer

How to check if a view exists before having it created?

Take the following view as an example: CREATE VIEW vw_types AS SELECT codigo AS code, nome AS description, abreviacao AS abbreviation, statusRegistro AS status FROM tipos How can I have it created only if it does not ex...
asked by 24.02.2015 / 14:14
1
answer

Track #hash and create description from it [LOGIC] [closed]

I came across this now and would like to debate to create a logic. Well, nowadays is used a lot of hashtags for everything in the main social networks, I almost never go to Twitter and when I enter I come across strange hashtags and do not kn...
asked by 20.12.2014 / 17:42
1
answer

How to put a SQL command in a variable

I have a following command in SQL and I need to put it inside a variable in SQL. That's the code. WITH DB_CPU_Stats AS (SELECT SUM(total_worker_time) AS [CPU_Time_Ms] FROM sys.dm_exec_query_stats CROSS APPLY (...
asked by 17.12.2014 / 17:49