I am trying to sort a particular column “TENOR” on the basis on maturity (group by Currencies) for eg – it should be sorted in the following order ON, SW, 1M, 2M, 3M, 6M, 9M, 1Y, 18M, 2Y and so on.. where ON = Overnight, SW = Single week and 1M = 1 month. i have tried using order by
Tag: sql-order-by
Column must appear in group by or aggregate function in nested query
I have the following table. I am trying to query the following: For each year that appears in the Fights table, find the city that held the most fights. For example, if in year 1992, Jersey held more fights than any other city did, you should print out (1992, Jersey) Here’s what I have so far but I keep getting
Select row in group with largest value in particular column postgres
I have a database table which looks like this. I need to group this table by id and select particular row where time_point has a largest value. Result table should look like this: Thanks for help, qwew Answer In Postgres, I would recommend distinct on to solve this top 1 per group problem: However, this does not allow possible to
How do I make ORDER BY work when creating a procedure in MySQL?
I’m trying to create a procedure that inserts the data of a new lecturer, then shows the last 3 lecturers added. This is what my table (lecturers) looks like: And this is my attempt to create the procedure: Then I call the procedure with this data for example: However, ORDER BY does not seem to be doing its job because
How to edit my postgreSQL query to select the most recent row by date for several columns
I have a query where I’m trying to select the most recent row based on date. So what I would like my query to do is to select the most recent datapoints for a couple columns in my database. sql = f&…
Finding the most active video maker within multiple tables(SQLite)
How can I find the initials of the most active video maker, the one that made the most videos considering the following tables using only one query? CREATE TABLE IF NOT EXISTS Videos ( title TEXT …
Psql query : Union is not preserving the order of rows coming from cte
I have this query: cte1 is ordered by salary column but cte2 is not. I want the results of cte2 to get appended to the results of cte1 while preserving the order of results from cte1. But it’s not happening. If I run the above query without union with the second cte, the results are displayed in the expected order
Group by one Column in Sql Server and Order by Another Column not contained in either an aggregate function or the GROUP BY clause
i have table “ApplicationEventsSearch” with two column Keyword and EventDate i want to have a query that return result as distinct keyword , but ordered asc by EventDate i have tried many combination , but none worked Data Desired Result and what i have tried so far Answer Aren’t you after just MIN or MAX in the ORDER BY?
How to sort numbers last in PostgreSQL?
Found many related answers, but nothing that did this. How to sort by numbers last: And, preferably (but not necessary) PostgreSQL 11.9 Also, probably don’t want to use a regex for performance reasons. Don’t want to create an index either… Answer I think a regex is the right way to do this: This puts first rows that contain no digit
what does this hyphen do between columns in order by clause in mysql query?
what does this hyphen do between updated_at and created_at columns in order by clause ? select * from `users` order by updated_at – created_at DESC