Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:40:15+00:00 2026-06-04T12:40:15+00:00

Given the following select statement: Select t.name, SUM(st.row_count) as row_count From sys.dm_db_partition_stats st join

  • 0

Given the following select statement:

Select t.name,  SUM(st.row_count) as row_count
From sys.dm_db_partition_stats st  
join sys.tables t on t.object_id = st.object_id
join ClientUpdateConfig c on t.name = c.TableName
Where  (index_id < 2)  and  schema_id = schema_id('dbo') 
and t.type ='U'
group by t.name

I would also like to select c.RowID as an additional field. The query works as it is but if I changed like 1 to:

Select t.name,  SUM(st.row_count) as row_count, c.RowID as current_row

I get the error:

Msg 8120, Level 16, State 1, Line 1 Column ‘ClientUpdateConfig.RowID’
is invalid in the select list because it is not contained in either an
aggregate function or the GROUP BY clause.

Can someone explain why I’d need the select value in the aggregate function (I’m assuming SUM) or in the group by to select it? I don’t understand this restriction – maybe I can adjust my query design if I can understand why this is happening.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:40:17+00:00Added an answer on June 4, 2026 at 12:40 pm

    Because it doesn’t know which RowId to select.

    You need either:

    . . .
    group by t.name, RowId
    

    or:

    select . . ., min(RowId) -- or max(RowId)
    

    Even if you know that there is only one RowId per name, the database does not know that, so you have to explicitly say what you want to do in the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following SQL: IF EXISTS (SELECT * FROM sys.columns WHERE name = 'NewFieldName'
Given following Statment: String query = "Select * from T_spareParts where SparePartPK IN (?
Given the following: select * from a; select * from b; Are these two
Problem Given the following two tables, I'd like to select all Ids for Posts
Given the following tables: CREATE TABLE tree ( id serial NOT NULL, name character
The sql statement is like this: select posts.id, posts.title from posts inner join (select
Say that I have some SELECT statement: SELECT id, name FROM people ORDER BY
Given the following javascript: function foo(selectControl) { ... } and the following html: <select
I use the following statement prepared and bound in ODBC: SELECT (CASE profile WHEN
SELECT SUM( CASE WHEN cumulative = 1 THEN percent ELSE 0 END) FROM phppos_items_taxes;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.