Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 group by limits??

Author  Topic 

kevison
Starting Member

5 Posts

Posted - 2008-03-07 : 10:25:09
I have a query below that does not work:


select
rc_display,levelid, AccountID, Customer_Number_Tby, rc_series, LanguageID, level_description, leveloptionsid,
rc_unique, levelrcid, ring, ring_eng_block, description, description_long, component, Company_name, logo_location, AccessType, login_Name, account_pin, cb_comments, Emblem_DNF
from tmpKevin
group by
rc_display,levelid, AccountID, Customer_Number_Tby, rc_series, LanguageID, level_description, leveloptionsid,
rc_unique, levelrcid, ring, ring_eng_block, description, description_long, component,company_name, logo_location, AccessType, login_Name, account_pin, cb_comments, Emblem_DNF
Having Count(rc_display) > 1


However if I strip out a few columns:
select
rc_display,levelid, AccountID, Customer_Number_Tby, rc_series, LanguageID, level_description, leveloptionsid,
rc_unique, levelrcid, ring, ring_eng_block, description, description_long, component, Company_name
from tmpKevin
group by
rc_display,levelid, AccountID, Customer_Number_Tby, rc_series, LanguageID, level_description, leveloptionsid,
rc_unique, levelrcid, ring, ring_eng_block, description, description_long, component,company_name
Having Count(rc_display) > 1


This works. I work on MS SQLServer 2000. Is there a field limit with the group by clause?

Thanks
Kevin

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-07 : 10:26:49
What do you mean by first query does not work? Do you get any error ?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

kevison
Starting Member

5 Posts

Posted - 2008-03-07 : 10:31:13
An empty recordset is returned( 0 row(s) affected) is what happens on the first query with all the columns.

Go to Top of Page

kevison
Starting Member

5 Posts

Posted - 2008-03-07 : 11:00:41
I found the problem. One of the columns (logo_location) contains unique data.

Thanks
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-03-07 : 11:05:10
Perfect example of the major difference between "Doesn't work" and "Doesn't return any records". There is a BIG difference in the two, especially when trying to figure out a "problem in syntax" or a "problem in design"



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

kevison
Starting Member

5 Posts

Posted - 2008-03-07 : 11:09:13
or a problem in the data... yeah... live and learn!
Go to Top of Page
   

- Advertisement -