Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the latest cumlative gpa
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00632402
Message ID:
00632543
Views:
13
One more way.
Select Gpauniq, Suniq, Cumgpa ;
	FROM gpahist g1 ;
	WHERE Str(Gpauniq) + Str(Suniq) IN ( ;
		SELECT Str(Max(Gpauniq)) + Str(Suniq) ;
			FROM gpahist ;
			GROUP BY Suniq)
>
* Using correlated query
>Select Gpauniq, Suniq, Cumgpa ;
>	FROM gpahist g1 ;
>	WHERE Str(Gpauniq) + Str(Suniq) IN ( ;
>		SELECT Str(Max(Gpauniq)) + Str(Suniq) ;
>			FROM gpahist g2 WHERE g2.Suniq = g1.Suniq)
>* If it's slow you can try to split it into two queries
>SELECT Max(Gpauniq) As Gpauniq, Suniq ;
>	FROM gpahist g2 ;
>	GROUP BY Suniq ;
>	INTO CURSOR crsMaxGpauniq
>Select g1.Gpauniq, g1.Suniq, g1.Cumgpa ;
>	FROM gpahist g1 ;
>   	  JOIN crsMaxGpauniq m1 ;
>		ON g1.Gpauniq = m1.Gpauniq ;
>			AND g1.Suniq = m1.Suniq
>
>
>>Hello Group,
>>
>>Every semester the students (suniq) cumulative gpa (cumgpa) is entered into
>>gpahist table. each cumulative gpa is given a gpauniq number. The largest
>>gpauniq integer for an associated suniq is the current GPA for that suniq.
>>
>>How do I change the following SQL to return one row for each suniq and the
>>latest cumgpa assoiated with it.
>>
>>SELECT gpauniq, suniq, cumgpa
>>FROM gpahist
>>
>>Thanks you
>>
>>Jim
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform