Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Group By 1

Status
Not open for further replies.

fanghua

Programmer
Feb 11, 2004
28
US
I want to display some data group by month. Is there anyway I can do it using <cfloop>? I would like to be able to insert a blank row if group changes. thanks!
 
Boy this'd be easier if you'd give some example code... with cfloop hmm...

The purpose of "otherfield" is to show you where to placeo ther data... and don't forget to specify a datasource.

Code:
<cfquery datasource="..." name="mq">
  select datef,otherfield from MyTable
  order by datef desc
</cfquery>

<cfset datex="">
<Cfloop query="mq">
  <cfif month(datef) neq datex>
    <br><b>#Dateformat(datef,"mmmm yyyy")#</b><br>
    <cfset datex=month(datef)>
  </cfif>
  &nbsp;&nbsp;other field: #otherfield#<br>
</cfloop>

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Yeah, there's that, but he specifically said cfloop so I thought that's what I'd give him.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top