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 6834303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:05:42+00:00 2026-05-26T23:05:42+00:00

I realize this is a very contrived example, but I’ve simplified the full version

  • 0

I realize this is a very contrived example, but I’ve simplified the full version down to the following which demonstrates the problem:

CREATE VIEW model.Appointments_Partition1
WITH SCHEMABINDING AS
  SELECT CONVERT(varchar(15), AppointmentId) as Id, 
         ap.AppTypeId as AppointmentTypeId, 
         ap.Duration as DurationMinutes, 
         ap.AppointmentId as EncounterId, 
         COUNT_BIG(*) as __count_big
    FROM dbo.Appointments ap 
    JOIN dbo.PracticeCodeTable pct ON SUBSTRING(pct.Code, 1, 1) = ap.ScheduleStatus 
                                  AND pct.ReferenceType = 'AppointmentStatus' 
   WHERE ap.AppTime > 0
GROUP BY CONVERT(varchar(15), AppointmentId), ap.AppTypeId, ap.Duration, ap.AppointmentId

CREATE UNIQUE CLUSTERED INDEX [IX_Appointments_Partition1_Id]
ON model.Appointments_Partition1 ([Id]);

I get:

Msg 8668, Level 16, State 0, Line 12
Cannot create the clustered index ‘IX_Appointments_Partition1_Id’ on view ‘PracticeRepository.model.Appointments_Partition1’ because the select list of the view contains an expression on result of aggregate function or grouping column. Consider removing expression on result of aggregate function or grouping column from select list.

I’m including count_big…so why is the group by a problem?….and how can I resolve the error?

  • 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-05-26T23:05:43+00:00Added an answer on May 26, 2026 at 11:05 pm

    Here is the same error message with some boolean logic applied to it:

    Cannot create the clustered index ‘…’ on view ‘…’ because the
    select list of the view contains an expression on a grouping column.
    Consider removing expression on a grouping column from the select list.

    You need to remove the CONVERT in CONVERT(varchar(15), AppointmentId)

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

Sidebar

Related Questions

I realize this is more of a hardware question, but this is also very
I realise that this is a very basic question, but it is one which
This seems like a very simple problem, but I cannot get a scrollbox to
I realize this is a very generic question, but I guess I'm not really
I realize this may be a very simple question but I need to know
I realize this question is very likely to have been asked before, but I've
I realize that this might be a duplicate question but this question is very
I realize this is very much of a long shot, but... In shell scripts
I realize this would violate convention, but I'm curious to know if you can
I realize this perhaps a naive question but still I cant figure out how

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.