Results 1 to 1 of 1
  1. #1
    Join Date
    Nov 2017
    Posts
    1

    Unanswered: How to use MAX on RANK()

    Hi,

    I need to rank over some values and then find the maximum value for rank; My query is as below:

    Code:
    SELECT MAX(SELECT rank() OVER (ORDER BY SUM(
      							CASE WHEN b.memid = 0 THEN b.slots * f.guestcost
      							ELSE b.slots * f.membercost END)DESC)
    			 FROM cd.bookings b
    		 	JOIN cd.facilities f ON b.facid = f.facid
    			GROUP BY f.name
    )  OVER() AS max_rank
    But I'm given following error:

    Code:
    ERROR: syntax error at or near "SELECT"
    what's wrong with that?
    Last edited by pinkypie; 11-15-17 at 17:47.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •