FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour FW_DbfSqlQuery GROUP BY no funciona
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
FW_DbfSqlQuery GROUP BY no funciona
Posted: Wed Feb 21, 2024 10:20 AM
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 (fw): Select all Collapse
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:


en cambio, en MySql sí que funciona:


si le quito GROUP BY
funciona correctamente


alguna idea?

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

Gracias!!
--------

¿ Y porque no ?

¿ And why not ?
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: FW_DbfSqlQuery GROUP BY no funciona
Posted: Wed Feb 21, 2024 03:37 PM

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.

--------

¿ Y porque no ?

¿ And why not ?
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW_DbfSqlQuery GROUP BY no funciona
Posted: Mon Feb 26, 2024 12:48 PM
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 (fw): Select all Collapse
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
Regards



G. N. Rao.

Hyderabad, India
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: FW_DbfSqlQuery GROUP BY no funciona
Posted: Tue Feb 27, 2024 02:05 PM

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.

--------

¿ Y porque no ?

¿ And why not ?

Continue the discussion