Results 1 to 3 of 3

Thread: Multiple sorting problem

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    3

    Multiple sorting problem

    Hello there, I have a sorting problem at the moment for multiple sorting.
    With a normal database i know how to multiple sort
    e,g SELECT A,B,C
    FROM Table1
    Order by A,B DESC

    My problem is that I want to insert data into a table from 2 joined tables. I can sort it once but i need it sort again a second time.


    my code is below
    strSQL = "INSERT INTO HIGHSCORE(PlayerId, CountScore) SELECT SCORE.PlayerId, Count(Player.Score_Date) AS CountOfScore_Date" & _
    " FROM SCORE INNER JOIN DETAILS ON SCORE.PlayerId = DETAILS.PlayerId" & _
    " WHERE (((SCORE.Score_Date) Between #" & varDateF & "# And #" & vardateT & "#)) ) " & _
    " GROUP BY SCORE.PlayerId" & _
    " ORDER BY Count(SCORE.Score_Date) DESC"
    I then produce a crystal report with output
    Surname Forename Score
    Shearer Alan 19
    Allen John 19
    Caldwell Gary 19
    Byrne Ian 19
    Smith John 18
    Childs Fred 18

    It shows the players with the highest score first, what i would like to know is there any way I can maybe sort the players by surname secondly afyer firstly sorting them by score to show output like:

    Allen John 19
    Byrne ian 19
    Caldwell gary 19
    Shearer Alan 19
    Chils Fred 18
    Smith John 18

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Multiple sorting problem

    would u just add it to the order by?

    ORDER BY Count(SCORE.Score_Date) DESC, Surname"
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Multiple sorting problem

    Easiest would be if Surname had its own field. How is the name data stored? One text field that always starts with surname?

Posting Permissions

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



Click Here to Expand Forum to Full Width