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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:51:02+00:00 2026-05-25T10:51:02+00:00

I am trying to do a SELECT using a CASE statement, and I ‘m

  • 0

I am trying to do a SELECT using a CASE statement, and I ‘m getting errors that do not make sense. My statement appears to adhere to any SQL syntax rules but I’m getting the good ol’ “the multi part identifier to_do.[item_id] AND to_do.[item] cannot be bound.
This does not make sense because the column names are correct with respect to the table columns.

Here is the SQL:

SELECT      to_do.[item_id],
            to_do.[item] = CASE to_do.encounter_id WHEN 0 THEN CONVERT(NVARCHAR, e.[date], 101 ) + ' - ' + p.[first_name] + ' ' + p.[last_name] + ' - ' + to_do.[item] AS to_do.[item] ELSE to_do.[item] END,
            to_do.[complete],
            to_do.[encounter_id],
            e.[date],
            p.[last_name] + ', ' + p.[first_name] AS [p_name]
FROM        [dbo].[to_do] LEFT OUTER JOIN
            [dbo].[encounter] e ON
                to_do.[encounter_id] = e.[encounter_id] LEFT OUTER JOIN 
            [dbo].[patients] p ON
                e.[mrn] = p.[mrn]
WHERE       to_do.[user_id] = @user_id

Any ideas what I’m doing wrong here ? Based off previous experience I should be able to use CASE like this but maybe I’ve just been staring at it too long and don’t see the obvious.
Thanks!

  • 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-25T10:51:03+00:00Added an answer on May 25, 2026 at 10:51 am

    You can’t use a table prefix in a column alias to_do.[item] = CASE ... is presumably intended to be [item] = CASE ...

    (Also you have a rogue AS in the middle of the CASE itself that needs removing)

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

Sidebar

Related Questions

I am trying to write a custom select statement in Hibernate using the getHibernateTemplate()
In trying to select elements that have any attributes, the following throws a jQuery
I am attempting to use a case statement but keep getting errors. Here's the
I am using following for select statement with case. The column to which the
Trying to read an RSS and select information using Linq but can't seem to
Using Django 1.1, I am trying to select the maximum value from a varchar
I am trying to read data from excel files using datatable. The command select
Without using plpgsql, I'm trying to urlencode a given text within a pgsql SELECT
Trying to select anchor tags that are a descendants of a div with a
I'm trying to mess around with putting CASE statement in the ORDER BY clause

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.