Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 To: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 Tags
Subject: RE: enginbehaviour
Thread ID: 288699 Message ID: 288967 # Views: 26 # Ratings: 1
Version: Visual FoxPro 9 SP2 Category: Projects and Design
Date: Monday, December 27, 2010 12:22:00 PM         
   


> >
> > You shouldn't use GROUP BY when there's no aggregation with any of the functions SUM(), COUNT(), AVG(), MIN() or MAX()
>
>
>
> Why must we use aggregation? Can you explain?
>
select religion,city from employees order by religion,city group by religion,city

> Would I have to use a aggregate function for the query above? Even if I don't need it?
> (Note: above is just a query from top of my head, as a example)
>
>
>
>
> > If there's only one possible wages for a given ecode+month you can use MAX(wages) or MIN(wages), SUM(wages), or AVG(wages(: they will all come to the same.
> > -Anders
>
>
>
> Regards
> Samir


Your query with GROUP BY (and no aggregation) still requires you to enumerate the same columns after GROUP BY and after SELECT, and .will generate the same result as
SELECT DISTINCT religion, city ..
and VFP may even execute them in the same way at the same speed.

Still the intended use for GROUP BY is in queries with a grouped aggregation function.
DISTINCT applies to the whole set of selected columns. If you have a table of 15 columns you can say
 SELECT DISTINCT * FROM Mytable
The same query with a GROUP BY clause would require you to list all 15 columns in the GROUP BY clause.


-Anders

ENTIRE THREAD

enginbehaviour Posted by vaishali maske @ 12/23/2010 10:09:04 AM
RE: enginbehaviour Posted by Cetin Basoz @ 12/23/2010 10:17:23 AM
RE: enginbehaviour Posted by vaishali maske @ 12/23/2010 10:59:06 AM
RE: enginbehaviour Posted by Anders Altberg @ 12/23/2010 2:56:09 PM
RE: enginbehaviour Posted by Rakesh Kumar @ 12/23/2010 3:39:27 PM
RE: enginbehaviour Posted by Anders Altberg @ 12/24/2010 2:23:32 AM
RE: enginbehaviour Posted by Rakesh Kumar @ 12/25/2010 1:03:31 PM
RE: enginbehaviour Posted by Samir H. @ 12/27/2010 10:19:44 AM
RE: enginbehaviour Posted by Michel Levy @ 12/27/2010 11:34:50 AM
RE: enginbehaviour Posted by Samir H. @ 12/27/2010 12:05:40 PM
RE: enginbehaviour Posted by Michel Levy @ 12/27/2010 12:55:39 PM
RE: enginbehaviour Posted by Cetin Basoz @ 12/27/2010 11:37:58 AM
RE: enginbehaviour Posted by Anders Altberg @ 12/27/2010 12:22:00 PM
RE: enginbehaviour Posted by Anders Altberg @ 12/27/2010 12:24:24 PM
RE: enginbehaviour Posted by Samir H. @ 12/27/2010 1:08:41 PM