[thelist] SQL Group By question

Tab Alleman talleman at Lumpsum.com
Wed Dec 6 14:57:09 CST 2006


If you really need that format of output, and you have an unknown number of groups, then there's no way to do it in a single query.  If you know the number of groups, you could do it with a UNION of 2xN queries.  

> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org]On Behalf Of Casey Crookston
> Sent: Wednesday, December 06, 2006 3:34 PM
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] SQL Group By question
> 
> 
> 
> SELECT a.* FROM vw_norfire_projects a
> WHERE a.JobType =
> (SELECT * FROM vw_norfire_projects WHERE JobType = a.JobType)
> 
> But that does not work...
> 
> Only one expression can be specified in the select list when the
> subquery is not introduced with EXISTS.
> 
> Is this something that will need to be done in the coding 
> logic and not
> the query?
> 
> 
> -- original message --
> 
> > If a table looks like this:>
> >
> > ID         Name    Group
> >
> > 1          NameA Group1
> >
> > 2          NameB Group1
> >
> > 3          NameC Group2
> >
> > 4          NameD Group2
> >
> > Is it possible to build a query that would return these results:>
> >
> > Group1
> >
> > NameA
> >
> > NameB
> >
> >
> > Group2
> >
> > NameC
> >
> > NameD 
> 
> 
> -- 
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester 
> and archives of thelist go to: http://lists.evolt.org 
> Workers of the Web, evolt ! 
> 



More information about the thelist mailing list