Solved

A single query

Posted on 2004-04-27
4
156 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
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Website being blocked? 3 122
IIS 8.5 2 51
Configure a Local PHP Interpreter for Phpstorm 2 192
.dwt files not viewable in browser - why? 2 75
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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

14 Experts available now in Live!

Get 1:1 Help Now