Questions tagged as 'query'

2
answers

Select picking up previous line

What do I have to use in SQL SERVER 2008 to pick up the line before a certain closing. For example if in my where below if the alert is = 99 I want to know the alert and the speed before the alert. Speed Data Alerta 58 '...
asked by 30.10.2017 / 13:22
1
answer

How to use aliases in queries using Aliases along with MySQL?

I would like to be able to use the 'AS' alias along with mysql without having to do query alignment, ie I want secondary queries to be named so that I can use them in the main query, For example, in the case below the AS is used nested...
asked by 01.12.2017 / 17:04
1
answer

Querying cities without repetition and with "WHERE" different

When trying to resolve a platform bank issue hackerrank I could not understand the answer after having found it in the discussion wing. The question says:    Query a list of CITY names from STATION with even ID numbers only. You may prin...
asked by 01.12.2017 / 03:05
1
answer

Query does not return WHERE set

I'm trying to query the Informix Database, and it's bringing in the data normally, but it's ignoring the search criteria. SELECT cnnfcapa.id_nfcapa, cnnfcapa.filial, cnnfitem.tpordem, cnnfcapa.ordemserv, cnnfcapa.dtnota, cnnfcapa.cgccpf,...
asked by 19.10.2017 / 04:05
1
answer

Query to count how many fields equal to 0 a record has

I need to return as many fields as 0 each record has and rank the one with the zeros down. Example: id | col2 | col3 | col4 1 | 1 | 0 | 0 2 | 0 | 0 | 0 3 | 0 | 1 | 4 4 | 0 | 3 | 5 5 | 3 | 2 | 40...
asked by 17.11.2017 / 16:54
1
answer

Update with select CTE Error

I'm having a hard time performing an update with select CTE. I want to refresh the taridinclusao field. Below is the query and just below is the update that I tried to perform, however, the following error occurs: "The 'historical' derived table...
asked by 27.09.2017 / 18:54
1
answer

Doubt - SQL Server Dates

In the script below when a given task is completed the other will open on the first business day of the subsequent month. Example : Task 10 was completed on day 18-11-2016 , then another will be generated on day 01-12-2016 . The...
asked by 25.09.2017 / 13:56
1
answer

Picking up the last value of each ID according to the highest final year

I have the following query : select f.id_user as user, f.id_tempo, t.ano_inicial, t.ano_final from fato as f inner join tempo as t where f.id_tempo = t.id_tempo; Which returns me the following table: What should I use in query...
asked by 03.10.2017 / 15:55
1
answer

Division of tables with Count and Sum

I'm working on a query where I have some sums and counts, and in some places I need to divide it into a table that I added or counted, for example: COUNT(M.ID_MAILING), SUM(CASE WHEN SS.IS_APPROACH = 1 THEN 1 ELSE 0 END) I need to divide th...
asked by 18.08.2017 / 12:48
1
answer

SQL query for more than one type of property, city and neighborhood does not work correctly

I got a template ready with some problems in the plugins and the queries. Of the 6 select fields to search for real estate, 3 of them can select more than once, type of property, city and neighborhood. The list of these 3 fields is generat...
asked by 28.08.2017 / 19:33