Page 1 of 1

FW_DbfSqlQuery GROUP BY no funciona

PostPosted: Wed Feb 21, 2024 10:20 am
by VictorCasajuana
Hola.
Estoy intentando hacer una consulta simple con la función FW_DBFSqlQuery pero cuando le añado GROUP BY me muestra error.

La consulta es la siguiente:
Code: Select all  Expand view
Function Main()

   TEXT INTO cQuery
      SELECT CODIGO, NOMBRE, COD_PRO
      FROM ARTICULO
      GROUP BY COD_PRO
   ENDTEXT
   oRs := FW_DbfSqlQuery( '.\DBF', cQuery,,.t.)
   xBrowse( oRs)

Return ( Nil )


la respuesta que obtengo es:
Image

en cambio, en MySql sí que funciona:
Image

si le quito GROUP BY
funciona correctamente
Image

alguna idea?

He buscado la documentación de FW_DbfSqlQuery() pero no la encuentro.

Gracias!!

Re: FW_DbfSqlQuery GROUP BY no funciona

PostPosted: Wed Feb 21, 2024 3:19 pm
by karinha

Re: FW_DbfSqlQuery GROUP BY no funciona

PostPosted: Wed Feb 21, 2024 3:37 pm
by VictorCasajuana
Thank's karniha
Before writing this post I have reviewed the forum content about fw_dbfSqlQuery() but I have not found any answer to my problem.

Re: FW_DbfSqlQuery GROUP BY no funciona

PostPosted: Mon Feb 26, 2024 12:48 pm
by nageswaragunupudi
Syntax of SQL Query has nothing to do with FWH function.
It is for the programmer to know the correct syntax of SQL supported by Jet OLE/ACE ole

Normally GROUP BY clause is used for Aggregate functions.
Example:
Code: Select all  Expand view
SELECT STATE,SALARY FROM CUSTOMER GROUP BY STATE ORDER BY STATE


Some Databases like MySql support GROUP BY without aggregate functions.
But all providers /databases do NOT support GROUP BY clause without Aggregate functions like MSSQL.ORACLE, Jet,ACE, etc

While dealing with DBF, we are concerned with Jet Oledb/ACE Oledb/VFPOLEDB.
None of them support GROUP BY clause without Aggregate functions.

It is rare to find anyone using GROUP BY clause if not for finding GROUPED TOTALS/AVERAGES. ETC

Re: FW_DbfSqlQuery GROUP BY no funciona

PostPosted: Tue Feb 27, 2024 2:05 pm
by VictorCasajuana
Thanks for your reply.
Indeed, I have seen that the problem is the SQL syntax. I am very used to using MySql for web purposes. Now it's time to learn MSSQL to be able to advance in FiveWin Harbour.