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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:51:11+00:00 2026-05-26T02:51:11+00:00

Simple structure table of employees Employee Manager Joe Smith Jon Smith Jon Smith Pete

  • 0

Simple structure table of employees

Employee      Manager
Joe Smith      Jon Smith
Jon Smith      Pete Stevens
Pete Stevens   NULL
Jared Scho     Pete Stevens
....

Im just trying to return some results but I want an indicator on whether the person is a manager or not so the result should be:

Employee       Manager      IsAManager
Joe Smith     Jon Smith         0
Jon Smith     Pete Stevens      1
Pete Stevens    NULL            1
Jared Scho    Pete Stevens      0

The result set is showing that Joe Smith and Jared Scho are not managers…

So If I had a simple SQL Query

SELECT
   Employee,
   Manager,
   As IsAManager   --tried to do a case statement here....
FROM
   Employee

I tried to do a case statement something to this effect:

SELECT CASE ISNULL(COUNT(*), 0) > 0 THEN 1 ELSE 0 END FROM Employee WHERE Manager = Employee

Not sure how to word it 🙂

  • 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-26T02:51:12+00:00Added an answer on May 26, 2026 at 2:51 am

    Hopefully this is just a demo example not your real table structure.

    SELECT Employee,
           Manager,
           CASE
             WHEN EXISTS(SELECT *
                         FROM   Employee e2
                         WHERE  e2.Manager = e1.Employee) THEN 1
             ELSE 0
           END As IsAManager
    FROM   Employee e1  
    

    For details of how SQL Server processes EXISTS Subqueries in CASE Expressions see this article.

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

Sidebar

Related Questions

I have a very simple table structure here. Just a list of words related
For quite a simple table structure, ie. Person, Criteria, and PersonCriteria (the combi-table), I
We are just upgrading our ASP.Net shop implementation (from simple one) to structure that
I got a really simple table structure like this: Table Page Hits id |
I have a parent/child table (simple tree) table structure (ID, ParentID), where I want
I have this kind of table for simple chat: messages table structure +----+---------+-----------+---------+------+------+ |
I have a simple table structure where each item row has a status. What
I have a simple table structure like this. What I would like to do
Given the following simple table structure (SQL Server 2008), I want to be able
I have a simple database structure like this: entries table +----+-----------+------------+-----------+------+ | id |

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.