?
Solved

A single query

Posted on 2004-04-27
4
Medium Priority
?
199 Views
Last Modified: 2013-12-24
Hi,
  If my table T1 is:
    ID    Name   group
    2     asdfas     mike
    3     klj;lkj       larry
    4     kljlj         mike


Is it possible to perform a single query that would do this:

Group Mike-Size=2
2   asdfas
4   kljlj

Group larry-Size=1
3 klj;lkj

??

Nick
0
Comment
Question by:SolverSurfer
4 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 1500 total points
ID: 10934082
try this...

<CFQUERY datasource="..." name="myquery">
      SELECT group, id, name
      FROM t1
      GROUP BY group, name, id
      ORDER BY group, name
</cfquery>
<CFOUTPUT query="myquery" group="group">
      <CFSET count = 0>
      <CFOUTPUT><CFSET count = count + 1></cfoutput>
      Group #group#-Size=#count#<BR>
      <CFOUTPUT>
      #id# #name#<BR>
      </cfoutput>
      <BR>
</cfoutput>
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 10934394
To me its not very clear what exactly you are after, can you eleborate if danrosenthals answer is not the answer your after, if it then don't worry ;-)
0
 
LVL 18

Expert Comment

by:Plucka
ID: 10935135
Hi SolverSurfer,

That makes two of us, have no idea what exactly you want the group by, looks like name, size.

Regards
Plucka
0
 
LVL 11

Expert Comment

by:hart
ID: 10936346
dan: with all due respect sir, ur code has got two group by's, i don't know why u need the one extra group by .., u could avoid it in the cfquery and only use it in the cfoutput.

Other than that ur solution should rock ;-)

SolverSurfer : Just a general advice, avoid using keywords like Name, Group etc.. as field names...

Regards
Hart


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question