Solved

A single query

Posted on 2004-04-27
4
144 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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Join & Write a Comment

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now