VBA problem

dUb
04-18-2001, 10:39 AM
I'm trying to take data into a db and then put it in excel but i've got an error. Here's the code:

Set rstORDERED = dbsGEMS.OpenRecordset("SELECT d.num_command, SUM(d.quantity*s.price) total FROM DETAIL_COMMAND d, STOCKCOMMANDS s WHERE d.pec=s.item GROUP BY d.num_command ORDER BY d.num_command;", dbOpenSnapshot, dbReadOnly)


and the error message is:

Run-time error '3075':

Syntax error (missing operator) in query expression
'SUM(d.quantity*s.price) total'.

but this query works perfectly in oracle sql plus

PWNettle
04-18-2001, 10:55 AM
I kind of doubt this worked with Oracle as written. You appear to have a syntax error where you alias your SUM. It should be:
<PRE> SELECT d.num_command, SUM(d.quantity*s.price) AS total FROM DETAIL_COMMAND d, STOCKCOMMANDS s WHERE d.pec=s.item GROUP BY d.num_command ORDER BY d.num_command</PRE>If that isn't the error then you're missing a comma at the same point:
<PRE> SELECT d.num_command, SUM(d.quantity*s.price), total FROM DETAIL_COMMAND d, STOCKCOMMANDS s WHERE d.pec=s.item GROUP BY d.num_command ORDER BY d.num_command</PRE>Paul

dUb
04-20-2001, 06:50 AM
thanx

it works

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum