Link to home
Start Free TrialLog in
Avatar of Favourites
Favourites

asked on

Limitation of Fields in "Group By " clause

I am having a query which consists of 40 fields from a
single table. I need to group on all the 40 fields in my
"SELECT" query. If I include all of them in my query,
in the "group by" clause, I get an error message which says,
"there is a limtation of only 16 fields in a "Group By" clause."

How will I include the rest of the fields in the "Group By"
clause ? Can I increase the limitations by setting options
(if any) in the client/server machine ?


Looking forward for a postive response and kind co-operation.
Avatar of sidcap
sidcap

Try to include in the "Group By" clause only the fields that you  really need to group ( generally, as maximum they are about 4 ); for  the rests of the SELECT fields you must need to apply them some grouping function like MAX(field), MIN(field), LAST(field).

Hope  this help !
SIDCAP.
Favourites, enough of yuor 40 fields are text fields that you can concatinate them (creating temp expressions) resulting in less than 16 fields to GROUP BY on.  And no, I know of no way to increase the setting options
Avatar of Favourites

ASKER

Assume that I have 45 fields in a table.
I am forced to have 40 fields out of 45 in my GROUP BY clause.
which is also present in SELECT clause.

In this case, how will include them in my GROUP BY clause ?
Give me an illustration of the above case.


ASKER CERTIFIED SOLUTION
Avatar of snydero
snydero

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Syndero,  JOINing several VIEWS with their own GROUP BY clauses will not give you the same result as doing GROUP BY on all those fields simulatneously.  Additionally, including the PRIMARY key in the VIEW will defeat the value of GROUP BY.

Favourites, if you have to see the fields AND group by them, then I think you are out of luck.  It just cannot be done by SQL.  You will have to create a temporary table and populate the values using multiple queries.  My suggestion above is only if you wanted GROUP BY but did not need to see them.
I have tried and succedded in other way.
I have tried and succedded in other way.