PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Problem with query
Problem with query
Iniciado por guest, 02,sep. 2016 21:07 - 6 respuestas
Publicado el 02,septiembre 2016 - 21:07
Have a query that runs perfect in msql management studio. Runs perfect thru the query editor in windev. But... a error show up when the project is compiled. Hence I can not get to the query to hook it into a table. Any Ideas.
Publicado el 02,septiembre 2016 - 21:21
Need more info. What's the error? Do you have example sql for us to look over? Also, which PCSoft product and version are you using?
Publicado el 02,septiembre 2016 - 22:17
Hi

on top of previous questions, what code do you use to execute it?

Best regards
Publicado el 02,septiembre 2016 - 22:33
SELECT
SUM(BOOKED_OPTION.BOOKEDOPTIONTOTALSELLINGAMOUNT) AS tsell,
BOOKING.BOOKINGID,
BOOKING.BOOKINGREFERENCENUMBER,
BOOKING.CLIENTID,
CLIENT.CLIENTNAME,
ADDRESS.ADDRESSLINE4,
BOOKING.BOOKINGSTARTDATE,
CLIENT.CLIENTID,
BOOKING.BOOKINGREFERENCENUMBER,
BOOKING.BOOKINGCONFIRMATIONDATE,
LOGIN_ACCOUNT.LOGINACCOUNTNAME,
BOOKING.BOOKINGCLIENTCONTACT,
BOOKING_STATUS.BOOKINGSTATUSNAME,
BOOKING.BOOKINGNAME,
STATE.STATENAME


FROM
BOOKING,
BOOKED_SERVICE,
BOOKED_OPTION,
CLIENT,
ADDRESS,
LOGIN_ACCOUNT,
BOOKING_STATUS,
STATE

WHERE
BOOKING.CLIENTID = 6058
AND BOOKED_SERVICE.BOOKEDSERVICEID = BOOKED_OPTION.BOOKEDSERVICEID
AND BOOKING.BOOKINGID = BOOKED_SERVICE.BOOKINGID
AND BOOKING.BOOKINGSTARTDATE BETWEEN '20160101' AND '20161231'
AND CLIENT.CLIENTID = BOOKING.CLIENTID
AND ADDRESS.CLIENTID = CLIENT.CLIENTID
AND LOGIN_ACCOUNT.LOGINACCOUNTID = OOKING.CREATEDBY_LOGINACCOUNTID
AND BOOKING_STATUS.BOOKINGSTATUSID = BOOKING.BOOKINGSTATUSID
AND STATE.STATEID = ADDRESS.STATEID

GROUP BY

BOOKING.BOOKINGID,
BOOKING.BOOKINGREFERENCENUMBER,
BOOKING.CLIENTID,
CLIENT.CLIENTNAME,
ADDRESS.ADDRESSLINE4,
BOOKING.BOOKINGSTARTDATE,
CLIENT.CLIENTID,
BOOKING.BOOKINGREFERENCENUMBER,
BOOKING.BOOKINGCONFIRMATIONDATE,
LOGIN_ACCOUNT.LOGINACCOUNTNAME,
BOOKING.BOOKINGCLIENTCONTACT,
BOOKING_STATUS.BOOKINGSTATUSNAME,
BOOKING.BOOKINGNAME,
STATE.STATENAME


this is the error code
Warning : The use of aggregate functions with other items or non-aggregate functions is not allowed without using a GROUP BY clause. All the items or non-aggregate functions must be found in the GROUP BY clause.
qwagents_by_year_direct_grand_totals_by_agent, SQL Code, line 1, column 1
Publicado el 02,septiembre 2016 - 22:38
using windev 21

native access
Publicado el 03,septiembre 2016 - 15:08
and again, your wlanguage code is?
Publicado el 03,septiembre 2016 - 16:29
Hi Joe,
If I understand your question correctly, take a look here:
http://stackoverflow.com/questions/5920070/why-cant-you-mix-aggregate-values-and-non-aggregate-values-in-a-single-select

What bothers me is that you say it works in Management Studio and the query editor in WinDEV (?). So maybe I got it wrong ....

But you can use "HExecuteSQLQuery" in "hQueryWithoutCorrection MODE".
http://doc.windev.com/en-US/index.awp…

-----------------------------------------------------------------------
When doing a query with GROUP BY, it is generally a good idea -with WX- to SPLIT your query, to 2 or more queries.

One query for the SELECT
and a second one on the FIRST query (Group etc.)

This way you bypass any syntax problems _AND_ it is a LOT faster, specially with HFSQL C/S .....
-------------------------------------------------------------------------

Steven Sitas
www.alpha360.biz