Solved

A single query

Posted on 2004-04-27
4
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 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