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?
selasAsked:
Who is Participating?
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.