Questions tagged as 'query'

2
answers

How to show the result of one query based on the result of another?

Query A: SELECT V.CHAPA AS CHAPA, F.NOME AS NOME, V.DATA AS DATA, DATEDIFF(mi, MIN(BATIDA), MAX(BATIDA)) AS DIFF FROM V_BATIDASANTIGAS AS V LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA = F.CHAPA WHERE V.BATIDA IS NOT NULL...
asked by 19.10.2016 / 18:10
1
answer

How do I update a field using it at the same time?

I would like to know if you have a way to sum the value of a line with itself without having to query after an update. I have a column called total that holds integers, at some point I want the value that is on this line to be s...
asked by 21.09.2016 / 05:05
1
answer

Calculate average with result of Pivot

I have a query that returns me the student grades in certain tests. The amount of test can vary. I use the Pivot command to transform the test names into columns and thus organize test / note, as shown in the following image: Where"SENEM_01"...
asked by 29.06.2016 / 16:32
1
answer

How to do INSERT on three tables with Stored Procedure?

I need to perform an insert in three related tables in the same query. I have the following scenario: Cidade, Estado e Pais How can I build a stored procedure on Sql Server for this?     
asked by 17.02.2016 / 02:36
2
answers

MySQL Query - Count different table fields

I need to create a view in MySQL where I get the following result. Col1 | Col2 Total Tab1 | Total Tab2 I'm using UNION as follows, but the result comes as follows: col1 Page 201 Page 5699 CREATE VIEW 'dashboards' AS ( select...
asked by 16.11.2015 / 14:01
3
answers

Execute DELETE only when returning SELECT

I have a routine where I update the local database with data from another database. I simply run a DELETE and then INSERT INTO tblX (SELECT * FROM tblY (tblY is a linked table)) , as below. The problem is that there is a time between DE...
asked by 25.04.2017 / 00:24
1
answer

Querying multiple tables in mysql

My template is as follows, I have 4 tables Avião (tailnum (PK), year) Voos (id_voo (PK), cancelled) Modelo (idmodel (PK), nome) Fabricante (id_fabricante (PK), nome) Airplane is with a 1: M link with the flights table and model, and the mod...
asked by 16.09.2015 / 00:12
1
answer

Query using LINQ and Generics C # [closed]

I'm having trouble running a LINQ query using Generics. Something like: from x in session.Query<T>() " ??? " My method receives two strings as parameters, columnName and search value. public virtual object PesquisePorColunaValor(...
asked by 22.09.2015 / 20:42
1
answer

Problem with LEFT JOINs joins and a condition [closed]

I have had this problem for some time now. I am counting on your help. I have 3 tables: publicacao id cartaz titulo 1 eradogelo.jpg A Era do gelo 2 ojogo.jpg O Jogo 3 helpme.jpg Help Me 4 please.jpg Pleas...
asked by 27.01.2015 / 20:20
1
answer

Product upgrade issue

In query the goal is to update the product unit, with a subquery that retrieves the current drive from the database and subtracts by checking by code. UPDATE loja.produto SET UNIDADE = (SELECT (SELECT UNIDADE FROM loja.produto WHERE CODIGO...
asked by 05.09.2015 / 18:56