SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Can't group on error.

    Greetings! I'm trying to get the top library users, when the user borrowed and returned a book 10 times or more, s/he belongs to the top library users. Here is my sql commant.

    PHP Code:
    SELECT  sb.stud_IdCOUNT(sb.stud_Id) >=10 AS total
    FROM    tbl_studentbook 
    AS sb
    LEFT JOIN tbl_student 
    AS s ON s.id sb.stud_Id
    WHERE   EXISTS
            
    (
            
    SELECT   stud_Id
            FROM    tbl_studentbook
            WHERE   sbook_Borrow 
    != '0000-00-00' AND sbook_Return != '0000-00-00'
             
    )
    GROUP BY total 
    My problem is I can't group it by total , error says that 'cant group on total' ..
    My purpose upon grouping it is that it will show only the id that pass the total value of 10.

    Any help? thank you.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    695
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    select stud_Id
      from tbl_studentbook
     where sbook_Return <> '0000-00-00'
     group by stud_id
    having count(*) > 10

  3. #3
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Thak you very much for the quick response sir. I works now.


Bookmarks

Posting Permissions

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