I HAVE DATA SET IN DRUID WITH "STUDENT_NAME","8EC0...
# general
p
I HAVE DATA SET IN DRUID WITH "STUDENT_NAME","8EC08_MARKS","8EC30_MARKS","8FC10_MARKS" NOW I WANT RESULT WITH THREE COLUMNS WITH NAMES IN THREE COLUMNS WITH ORDER RESPECTIVE TO THE MARKS IN DESCENDING ORDER FOR INSTANCE 1ST COLUMN WITH STUDENT NAMES IN THE ORDER OF 8EC08_MARKS,SECOND COLUMN WITH STUDENT NAMES IN ORDER OF 8EC30_MARKS AND THIRD COLUMN WITH STUDENT NAMES IN ORDER 8FC10_MARKS IN DESCENDING ORDER PROVIDE A DRUID QUERY FOR IT
j
Hi Pinnuri, Here is one way to do it, using Window Functions to compute the ranks for each of the fields. This example uses the wikipedia demo datasource, but you can apply the same pattern to your table:
Copy code
with tmp_added as (
 select channel, sum(added) Added, rank() over (order by sum(added) desc, channel) Rnk from wikipedia group by channel
), tmp_comment as (
 select channel, max(commentLength) Comment, rank() over (order by max(commentLength) desc, channel) Rnk from wikipedia group by channel
), tmp_delta as (
 select channel, avg(delta) Delta, rank() over (order by avg(delta) desc, channel) Rnk from wikipedia group by channel
)
select a.Rnk, a.channel Added, c.channel Comment, d.channel Delta
  from tmp_added a
  join tmp_comment c on a.Rnk = c.Rnk
  join tmp_delta d on a.Rnk = d.Rnk
If you have any issues getting this to work please post your query and we can help. To enable window functions remember to add the query context
enableWindowing: true
Please note, that Group By is required to use Window Functions with the native query engine (when MSQ supports WindowFns it won't require it).