Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB 6 ado open using VFP 6 sql select with group by 1

Status
Not open for further replies.

ashmac2

Programmer
Mar 3, 2003
11
US
I have the following code that is giving me an invalid Group by clause error:
Code:
Set adoPrimaryRS = New Recordset

->  adoPrimaryRS.Open "SELECT userid, max(saidtime) AS saidtime, actualtime, punchtype, description, returntime FROM punches WHERE saidtime > DATE() GROUP BY userid", db, adOpenStatic, adLockOptimistic
The sql select statement works fine in VFP and only errors out here. Any ideas? Thanks in advance.

Laura Savana
 
I believe your group by clause has to reference "actualtime, punchtime, description and returntime" as well, but not aggregate functions such as "max".

HTH

Many Thanks!

AMACycle

American Motorcyclist Association
 
Thanks, that got me thinking in the right direction and we managed to get our results in the following way:
Code:
SELECT userid,saidtime,actualtime,punchtype, ;
              descriptio,returntime ;
	FROM c:\matt\data\punches ;
	WHERE saidtime >= DATE() AND ;
              userid+TTOC(saidtime) IN ;
	(SELECT userid+TTOC(MAX(saidtime)) ;
		FROM c:\matt\data\punches ;
		WHERE saidtime >= DATE() ;
		GROUP BY userid)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top