Questions tagged as 'order-by'

2
answers

Dynamically sort SQL result

First of all, Working specifically with Java in the Backend using WebServices Rest and PostgreSQL, after some professional enhancements I was directed to pass ordering and paging of my application to SQL, which would overload the application ser...
asked by 18.09.2017 / 21:26
0
answers

Sort by deep JSON column

I have a column called data , which has, for example, this JSON    [{"name": "unit", "value": "2", "validator": ["required"]}, {"name": "name", "value": "teste", "validator": ["required"]}] I need to make a SELECT that...
asked by 03.10.2017 / 22:21
1
answer

Order by SQL Server in Procedure

Hello, I am in the following situation: I need to select the amount of care of people of some age groups and of those who are male and female. I have the following tables: cadastro (id, natendimento, data, sexo, fokfaixaetaria) and fa...
asked by 02.09.2015 / 21:31
1
answer

select distinct in temp table sql server

I have the following code: (it is from a table that the representatives have the same code, which generates duplicate values, I solve this by picking the most current representative, in short the last face that synchronized) / em> select dist...
asked by 04.10.2018 / 21:41
1
answer

Search with group by

Suppose the following table that records author posts in a blog. An author can have several posts. So I have several reps of authors on this table of the different posts he made. How do I make a query to fetch the content of the most re...
asked by 23.09.2018 / 05:54
2
answers

SELECT sort by quantity of another SELECT

I have two tables in MYSQL: account: id apelido_usuario 1 caio 2 manoel 3 josé product idconta status 1 3 1 3 1 1 2 3 3 2 I made a SELECT like this: SELECT * FROM conta WHERE apelido_usuar...
asked by 21.09.2015 / 20:00
1
answer

mysql select order by starting today's date

I have this query that looks for birthdays of the month: $mesHoje = date("m"); $sqlAni = $pdo->prepare('SELECT * FROM aniversario WHERE MONTH(dia) = :mesHoje ORDER BY dia ASC'); $sqlAni->execute(array("mesHoje" => $mesHoje)); How d...
asked by 23.10.2018 / 16:29
1
answer

ORDER BY or LIMIT. What is first processed in SQL Select?

Friends, what is first processed in SQL Select? The "Order by" or "Limit"? For example, if I have a table with multi-state cities. Then I look for cities with more than 100 thousand inhabitants of state X, resulting in 6 cities (eg cities lis...
asked by 07.06.2018 / 09:27
1
answer

How to sort a group in the mysql query?

I'm trying to sort a query in the database by grouping the information, however this is showing the first one registered in the database, but I want the last. SELECT * FROM base_rating AS B JOIN historico_rating AS H ON B.id = H.id_base_rating...
asked by 28.08.2017 / 20:20
3
answers

Problem when ordering sql with orderby Date in postgresql

I have the following Query that results in joining the total sum of an account and the plots select sum(total) as total, datavencimento from ( select sum (con_valoraserpago) as total, to_char(con_datavencimento...
asked by 09.08.2017 / 01:25