Questions tagged as 'order-by'

2
answers

MYSQL: sort by specific rows within SELECT

I've been trying to resolve this for about three days and found the answer nowhere. I have a table in the database where I need to do a SELECT on all products but they need to be sorted according to the average between date X and date X, a ba...
asked by 04.03.2017 / 18:11
1
answer

Linq to SQL - Dynamic ordering by column index

I'm using a component called datatables.js ( link ) to display my tables and it has the ServerSide strong>, which I call, in Ajax, my list from somewhere. It sends the ordering, meaning by parameters. It sends the Index column to be sorted....
asked by 11.12.2015 / 20:34
2
answers

Create a custom order in SQL

I have a table ( groups ) in SQL with the following structure: id | name | description | display_order | ... The display_order field was set to UNIQUE and should be an integer. Its main function is to be used to create a...
asked by 19.05.2018 / 03:51
1
answer

SQL query using order by filtering through the records [closed]

I have the table: | cod | hora | produto | Amostra | Min | Max | |-----|-------|---------|---------|-----|-----| | 1 | 08:00 | 96722 | 1 | 100 | 200 | | 2 | 08:23 | 96721 | 1 | 90 | 90 | | 3 | 08:50 | 96722 | 2...
asked by 06.09.2016 / 16:08
1
answer

From CTE in SQL for relational algebra

How to pass a CTE in SQL to relational algebra, such as: with publicacao_cte (nome,nr_publicacoes) AS ( select candidato.nome, Count(1) as nr_publicacoes from candidato, cv, ficha_inscricao, publicacao_cv where candidato.bi = ficha...
asked by 20.11.2015 / 18:53
4
answers

Sort a SELECT in MySql by a letter

How can I make a SELECT query in MySQL that sorts the results and initially presents those that begin with a specific letter? Ex with the letter P: Paulo Patricia (1st ones starting with the letter) Filipe (2nd those with the letter in the mi...
asked by 01.08.2018 / 21:29
1
answer

How to query MYSQL in 2 columns and sort 1st results of column title and then column description

I am setting up a job agency website and I have a search that looks in the field title and description, what the person searched, as per the query below: SELECT * FROM vagas WHERE (titulo LIKE '%termo_de_busca%' OR observacoes LIKE '%termo_de_...
asked by 31.08.2018 / 14:33
1
answer

MySQL SELECT with ORDER BY in GROUP BY

I have a table called contacts , where all contacts made on the site are registered. There is also a table named status , where the service status of each contact is stored. In doubt, I need to SELECT contacts, and in LEFT JOIN only show...
asked by 13.06.2018 / 13:31
1
answer

Select with max (date), penultima (date)

I have a table with product code and date of sale. I would like to make a select picking the product code, the date of the last sale and the date of the next-to-last sale with group by code. Is it possible? select p.codigo, max(date_format(p...
asked by 13.01.2017 / 14:21
1
answer

Is it a bug in CakePHP - Sort Aliases?

I'm trying to sort a query by relevance with cakephp using paginator, but it simply ignores the alias, I already researched the manual but so far I have not found the solution, the query works perfectly, when I give a debug it generates the quer...
asked by 24.05.2014 / 00:43