Skip to content
Advertisement

Tag: sql-order-by

How do I order categorical data in SQL to match a list of names?

How would I order a column of categories based on a specified (and ordered) list of just those category names? For example, let’s say the names of groups a, b, and c, are listed in descending order based on their respective group mean blood pressure as [b,a,c] (with b having the highest mean blood pressure, and c the lowest). Going

How to select MAX from AVG?

I’m practicing for my SQL exam and I can’t figure out the following question: “Of the average amount paid per customer, show the highest amount.” So to retrieve the average amount paid, I would do the following: Then I would like to retrieve the highest average amount out of this list of averages. I thought the following would do the

How to use order by after group by sql

I have a table like this: and I need to group by and order on positionNr. I tried with this query: But I obtain something like this: But what I want is a result like this: Please can you help to understand where is the problem on the query? Answer Based on your expected result, it seems that: 1- You

Advertisement