techdocsmith commented on code in PR #17670:
URL: https://github.com/apache/druid/pull/17670#discussion_r1932950140
##########
docs/querying/sql-functions.md:
##########
@@ -1820,6 +1851,36 @@ Returns the rank for a row within a window without gaps.
For example, if two row
* **Syntax**: `DENSE_RANK()`
* **Function type:** Window
+<details><summary>Example</summary>
+
+The following example returns the dense rank by airline for flights from two
airports on a single day.
+
+```sql
+SELECT FLOOR("__time" TO DAY) AS "flight_day",
+ "Origin" AS "airport",
+ "Reporting_Airline" as "airline",
+ COUNT("Flight_Number_Reporting_Airline") as "num_flights",
+ DENSE_RANK() OVER (PARTITION BY "Origin" ORDER BY
COUNT("Flight_Number_Reporting_Airline") DESC) AS "dense_rank"
+FROM "flight-carriers"
+WHERE FLOOR("__time" TO DAY) = '2005-11-01'
+ AND "Origin" IN ('KOA', 'LIH')
+GROUP BY 2, 3, 1
+```
+
+Returns the following:
+
+| `flight_day` | `airport` | `airline` | `num_flights` | `dense_rank` |
+| --- | --- | --- | --- | ---|
+| `2005-11-01T00:00:00.000Z` | `KOA` | `HA` | `11` | `1` |
+| `2005-11-01T00:00:00.000Z` | `KOA` | `UA` | `4` | `2` |
+| `2005-11-01T00:00:00.000Z` | `KOA` | `AA` | `1` | `3` |
+| `2005-11-01T00:00:00.000Z` | `KOA` | `NW` | `1` | `3` |
+| `2005-11-01T00:00:00.000Z` | `LIH` | `HA` | `15` | `1` |
+| `2005-11-01T00:00:00.000Z` | `LIH` | `AA` | `2` | `2`|
+| `2005-11-01T00:00:00.000Z` | `LIH` | `UA` | `2` | `3` |
Review Comment:
Verified.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]