• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

error: not a group by expresion

I try to group dbgrid data and get this error

  AdoQuery1.SQL.Clear;
  AdoQuery1.SQL.Add('Select fcarte.id_clcrd, ptkpts.id_cli, ptkpts.id_typpts, typpts.lnglab, nbr_pt_vie from fcarte, ptkpts, typpts');
  AdoQuery1.SQL.Add('where ptkpts.id_typpts = typpts.id_typpts');
  AdoQuery1.SQL.Add('group by ptkpts.id_typpts');
  AdoQuery1.Open;

How to solve it?
0
selas
Asked:
selas
  • 2
  • 2
1 Solution
 
vadim_tiCommented:
You need GROUP BY only when use aggregate function, but in your query you do not have any aggregate function.

Try to explain what exactly you want to do
0
 
selasAuthor Commented:
Thanks :) i forgot to make a sum :/
0
 
selasAuthor Commented:
I still dot understood why this query not work?

  AdoQuery1.SQL.Clear;
  AdoQuery1.SQL.Add('Select id_cli, id_typpts, sum(mnt_nr), sum(nbr_pt) from fmouvem group by id_typpts');
  AdoQuery1.Open;
0
 
vadim_tiCommented:
you need to make

 AdoQuery1.SQL.Clear;
  AdoQuery1.SQL.Add('Select id_cli, id_typpts, sum(mnt_nr), sum(nbr_pt) from fmouvem group by id_cli, id_typpts');
  AdoQuery1.Open;

or

 AdoQuery1.SQL.Clear;
  AdoQuery1.SQL.Add('Select id_typpts, sum(mnt_nr), sum(nbr_pt) from fmouvem group by id_typpts');
  AdoQuery1.Open;

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now