GROUP BY clause

Results 1 to 2 of 2

Thread: GROUP BY clause

  1. #1
    Join Date
    Dec 1969

    Default GROUP BY clause

    How can i use this group by clase properly?<BR><BR>Actually i want to show field1,field2 from database, then i want it to sort order by field1, then group by fields 2. I try to put the &#039group by&#039 clause at the last, however an error occur.<BR><BR>My sql statement is:<BR>"select FMDatePosted,FMThreadID from forummessage order by FMdateposted desc group by fmthreadid "<BR><BR>Please help me to edit.<BR><BR>TQ&#062;

  2. #2
    Ugh!! Guest

    Default RE: GROUP BY clause

    To give you the exact syntax it depends what aggregate function you want to apply on the data. If you want to group by threadid and show the most recent date posted for each thread, for example, the syntax would be &#060;something&#062; like this:<BR><BR>SELECT MAX(FMDatePosted),FMThreadID <BR>FROM forummessage <BR>GROUP BY fmthreadid <BR>ORDER BY MAX(FMdateposted) DESC <BR><BR>What exactly are you trying to achieve ?<BR><BR>Regards<BR><BR>Ugh!!

Posting Permissions

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