4 Replies Latest reply on Sep 25, 2006 7:09 AM by Dan Bracuk

    order by

    JohnGree Level 1
      Hi i have a dynamic list box, what i need to do is order the list box by SeasonID Desc

      i have tried the standard order by but with no luck

      any ideas
        • 1. Re: order by
          azadisaryev Level 1
          add ORDER BY SeasonID DESC on a new line after WHERE clause in your query.

          btw, what is 'Season' (which you use in the WHERE SeasonID = Season)? If it is a variable you pass to your query, you better surround it with ##...
          • 2. Re: order by
            JohnGree Level 1
            yes i have tried that but dont work, there are two tables that i am joining, thats why i am getting no order by

            <cfquery name="ShowDate" datasource="Cricket">
            SELECT DISTINCT SS.SeasonID, SS.SeasonYear, BB.Season
            FROM SeasonTable SS, BattingStats BB
            WHERE SS.SeasonID = BB.Season
            </cfquery>
            • 3. Re: order by
              azadisaryev Level 1
              have you tried using INNER JOIN in your query instead?

              SELECT DISTINCT SS.SeasonID, SS.SeasonYear, BB.Season
              FROM SeasonTable SS INNER JOIN BattingStats BB ON SS.SeasonID = BB.Season
              ORDER BY SS.SeasonID DESC

              i am not quiet sure if you can use table aliases with INNER JOIN.. so you may have to use full table names instead if the above does not work...
              • 4. Re: order by
                Dan Bracuk Level 5
                quote:

                Originally posted by: JohnGree
                yes i have tried that but dont work, there are two tables that i am joining, thats why i am getting no order by

                <cfquery name="ShowDate" datasource="Cricket">
                SELECT DISTINCT SS.SeasonID, SS.SeasonYear, BB.Season
                FROM SeasonTable SS, BattingStats BB
                WHERE SS.SeasonID = BB.Season
                </cfquery>


                Based on what you are showing us, the reason you are not getting an order by is because you are not typing it into your query.