Source language: Translate to:

Max() function in SQL statements

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Max() function in SQL statements

Postby calamar » Thu May 05, 2011 4:17 am

Hi all!

I'm trying to do an dbpExecSQL query like this:

Code: Select all
SELECT  s.nombre, v.version, Max(a.fecha)
FROM    software s, versiones v, actualizaciones a
WHERE   a.impresoras_matricula = [parametro-1] AND
        s.ID = [maquina-db.software.ID] AND
        a.versiones_ID = v.ID AND
        v.software_ID = s.ID;


The query is for taking the last software update made on a specific machine. So I'm using the MAX() function to get the latest update.

The thing is that when this command is executed, I get the error message:

"_Max(a.fecha)" is not a valid component name.


Can I use Max() function on my SQL statements?

Thanks.
@mt!
===
User avatar
calamar
 
Posts: 9
Joined: Mon Jan 05, 2009 4:52 am

Postby calamar » Thu May 05, 2011 4:20 am

The curious thing is that, when I make a step-by-step execution of the program, I get:

Code: Select all
[maquina-db.auxiliar.Max(fecha)] = 12/03/2011


So the value gets correctly.
@mt!
===
User avatar
calamar
 
Posts: 9
Joined: Mon Jan 05, 2009 4:52 am

About Using Max()

Postby carlos torres » Thu May 05, 2011 6:18 am

Dear Calamar

I figure out that one of the best ways to do that is designing the SQL statement in Access then copy the SQL made by Access to the NB editor (dbpExecSQL)

regards
carlost
User avatar
carlos torres
 
Posts: 289
Joined: Mon May 02, 2005 8:14 am
Location: Pamplona, Colombia

Postby calamar » Thu May 05, 2011 6:24 am

Thanks for the answer.

I tested the SQL statement on "MySQL Workbench" (it's a MySQL database) and it worked ok.
@mt!
===
User avatar
calamar
 
Posts: 9
Joined: Mon Jan 05, 2009 4:52 am

Postby Neosoft Support » Thu May 05, 2011 10:15 am

DBPro simply passes your SQL statement along to the database engine through the ADO/ODBC interface. DBPro then reports any error messages returned by the database engine. Since connecting to the database through an intermediary interface isn't the same as connecting directly, it's possible that some types of SQL statements might not work.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby David de Argentina » Thu May 05, 2011 2:33 pm

Hi Calamar,

Try with:

[maquina-db.auxiliar.Max(fecha)] = 20110312

instead

[maquina-db.auxiliar.Max(fecha)] = 12/03/2011

Date evaluations must be done with "YYYYMMDD" date format

my 0.01
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 2 guests