[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [SQL] group by hjælp



Onsdag 30 maj 2007 21:42 skrev Hans Schou:
> On Wed, 30 May 2007, Michael Rasmussen wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On Wed, 30 May 2007 21:30:10 +0200 (CEST)
> >
> > Hans Schou <sslug@sslug> wrote:
> >> Hvis to salgsteder har samme mindste pris, vises de begge. (hvilket
> >> vel også er matematisk korrekt)
> >
> > Kan dette ikke undgås med en select distinct?
>
> Det er jeg ikke lige mand for at bevise. Jeg prøvede i praksis, men
> kunne ikke få det til at funge.
>
> /hans

I PostgreSQL kan man gøre noget a la 

SELECT DISTINCT ON (bogtitel, pris) bogtitel,salgssted,pris
 FROM bog a 
NATURAL JOIN 
 (SELECT DISTINCT bogtitel,min(pris) AS pris
 FROM bog 
GROUP BY bogtitel) b;

Men det er vist ikke standard, så det opfylder næppe kravet om at kunne bruges 
i MySQL.

-- 

Med venlig hilsen
Kaare Rasmussen, Jasonic

Jasonic                 Telefon: +45 3816 2582
Nordre Fasanvej 12
2000 Frederiksberg      Email: sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-06-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *