Solved

A single query

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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