Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GROUP BY clause is missing or invalid (FoxPro OLEDB)
Message
From
19/11/2004 08:15:56
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
18/11/2004 11:21:09
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
VB.NET 1.1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00962667
Message ID:
00962942
Views:
7
>Hi,
>I have table where order info and order details placed to one table. Its de-normalize table structure. I'd like to get list of unique orders from there (interne_nr - orderID)
>
>my code is
>
>lcSQL = "SELECT mkstech_arbzeit.interne_nr," & _
>    "mkstech_arbzeit.benutzer, " & _
>    "mkstech_arbzeit.status," & _
>    "mkstech_arbzeit.descr," & _
>    "mkstech_arbzeit.datum," & _
>    "mkstech_kunden.kurzbez" & _
>      " FROM mkstech_arbzeit INNER JOIN mkstech_kunden ON " & _
>      " mkstech_arbzeit.kundnr=mkstech_kunden.kundnr " &
>      " GROUP BY 1 " & _
>      " ORDER BY 1 "
>
>     Dim loConnection As OleDbConnection
>     Dim loCommand As OleDbCommand
>     loConnection = Me.mmks_getconnection()
>     loCommand = New OleDbCommand(lcSQL, loConnection)
>     loConnection.Open()
>     Dim loDataReader As OleDbDataReader = loCommand.ExecuteReader()
>
>Last line return me error GROUP BY clause is missing or invalid
>
>Any ideas how can I get the unique list of orders?
>Notes:
>Using VFP OLEDB Provider.
>
>Thanks.
>Denis.

Denis,
It's the engine thing as you already learned.
The new engine makes it the right way and doesn't let you run illogical groupings unless you had a good reason (and sometimes there are).
Rethink your SQL:
SELECT mkstech_arbzeit.interne_nr, ;
    mkstech_arbzeit.benutzer, ;
    mkstech_arbzeit.status, ; 
    mkstech_arbzeit.descr,;
    mkstech_arbzeit.datum,;
    mkstech_kunden.kurzbez ;
       FROM mkstech_arbzeit INNER JOIN mkstech_kunden ON ;
       mkstech_arbzeit.kundnr=mkstech_kunden.kundnr ;
       GROUP BY 1 ;
       ORDER BY 1 
Converting group by to: GROUP BY 1,2,3,4,5,6 is not a solution just a bypassing of potential logical error.
If it's a solution then shortly you could instead use DISTINCT clause.
create cursor test (interne_nr i,datum d)
insert into test values (1, {^2004/1/1})
insert into test values (1, {^2004/2/1})
insert into test values (1, {^2004/4/1})
insert into test values (1, {^2004/3/1})
Select distinct interne_nr, datum ;
       FROM test ;
       ORDER BY 1 

SELECT interne_nr, datum ;
       FROM test ;
       GROUP BY 1,2 ;
       ORDER BY 1 

SET ENGINEBEHAVIOR 70 && As it was in 7
SELECT interne_nr, datum ;
       FROM test ;
       GROUP BY 1 ;
       ORDER BY 1 
SET ENGINEBEHAVIOR 80
Notice implicit order by (which is wrong IMHO) and none might be what you want. EngineBehavior changes are not limited to GROUP BY. Read VFP documentation about it.

PS: "SET ENGINEBEHAVIOR" is a supported VFPOLEDB command. You'd do something like:

Dim cmdInit As OleDbCommand
cmdInit = new OleDbCommand("set enginebehavior 70",loConnection)
cmdInit.ExecuteNonQuery()

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform