SELECT Max() help...

Results 1 to 2 of 2

Thread: SELECT Max() help...

  1. #1
    Join Date
    Dec 1969

    Default SELECT Max() help...

    I am trying to do the following:<BR><BR>I have a table with 6 fields (url + 5 rating fields 1-5)<BR><BR>I need to find the highest rating for one record in the db i.e the highest rating for a particular url. I have tried the following, but it won&#039;t work:<BR><BR>SELECT Max(Rating_1, Rating_2, Rating_3, Rating_4, Rating_5) AS Highest FROM MyTable WHERE Url=&#039;";;<BR><BR>Any suggestions as I&#039;m stumped!!<BR><BR>Thanks<BR><BR>Micheal

  2. #2
    Join Date
    Dec 1969

    Default Terrible database design.

    You can probably do this in a SQL statement, but I don&#039;t feel like thinking about it. Do it in ASP:<BR><BR>Dim iCnt, iHighestRating_ID, iHighestRating_Value<BR> iHighestRating_Value = -10000<BR>For iCnt = 1 To 5<BR> If oRS.Fields("Rating_" & iCnt).Value &#062; iHighestRating_Value Then<BR> iHighestRating_ID = iCnt<BR> iHighestRating_Value = oRS.Fields("Rating_" & iCnt).Value<BR>Next<BR><BR>-Doug

Posting Permissions

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