main logo
Subject: Re: Sort on group totals
Author: Chester Friesen
Posted: 2007/01/31 23:49:04
 
View Entire Thread
New Search


Vince Teachout wrote:
> Well, Here's one way:
>
> SELECT rider, SUM(nscore) as totscore FROM foobar GROUP BY rider INTO
> CURSOR totcurs nofilter
>
> SELECT Foobar.Rider, Foobar.Ddate, Foobar.Nscore, totcurs.totscore ;
> FROM foobar INNER JOIN totcurs ON foobar.rider = totcurs.rider ;
> ORDER BY 4 desc,1
>
Hey Vince, you got me on the right track, thanks a million! Here's how I
did it, I haven't got it into a report yet because I need some more
inner joins to get the rider names into it, but I think it will work.

SELECT riderid, ;
SUM(nscore) AS totscore ;
FROM Foobar;
GROUP BY riderid ;
ORDER BY totscore DESC ;
INTO CURSOR totcurs nofilter

SELECT * ;
FROM Foobar;
INNER JOIN totcurs ;
ON Foobar.riderid = totcurs.riderid ;
ORDER BY totscore DESC,1

BTW, what does the 4 do after the Order By, also the 1 after the Desc?

--
Regards,
Chester Friesen
Friesen Computer Company
Willows, CA




 
©2007 Chester Friesen
<-- Prior Message New Search Next Message -->