FW_DbfSqlQuery GROUP BY no funciona

FW_DbfSqlQuery GROUP BY no funciona

Postby VictorCasajuana » 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: 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!!
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 265
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs


Re: FW_DbfSqlQuery GROUP BY no funciona

Postby VictorCasajuana » Wed Feb 21, 2024 3: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 ?
User avatar
VictorCasajuana
 
Posts: 265
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: FW_DbfSqlQuery GROUP BY no funciona

Postby nageswaragunupudi » 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: 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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10633
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_DbfSqlQuery GROUP BY no funciona

Postby VictorCasajuana » Tue Feb 27, 2024 2: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 ?
User avatar
VictorCasajuana
 
Posts: 265
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 44 guests