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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:29:50+00:00 2026-05-15T01:29:50+00:00

I have two tables Employee ID | Name | Department ———————- 121 |Name1 |

  • 0

I have two tables

Employee

ID | Name | Department
----------------------
121  |Name1  | dep1
223  |Name2  | dep2

Assignment

ID | EID| 
---------
1  |121
2  |223
3  |121

[other columns omitted for brevity]

The table assignment indicates which is work is assigned to whom.EID is a foriegn key to the table Employee.Also it is possible to have two work assigned to the same employee.

Now i want to create a view like this

EID | Assigned
--------------
121 |true
333 |false

Assigned column should be calculated based on the entries in the Assignment table.

So far i am only successful in creating a view like this

EID | Assigned
--------------
121 |2
333 |0

using the command

CREATE VIEW "AssignmentView" AS
SELECT distinct ID ,(select Count(*)
from Assignment where Assignment.EID = Employee.ID) as Assigned
FROM  Employee;

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-15T01:29:51+00:00Added an answer on May 15, 2026 at 1:29 am

    The CASE expression and a GROUP BY should do the trick:

    Select
      e.id,
      Case When Count(a.eid) > 0 Then 'true' Else 'false' End As assigned
    From employee e
    Left Join assignment a On ( a.eid = e.id )
    Group By e.id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, one Company and one Employee: class Company(models.Model): name = models.CharField(max_length=60)
I have two tables Department and Employee . Department table looks like this: ID
I have two tables - `employee` and `department`. 1. `employee` table contains column id,employee
So my situation is this. I have two tables, e.g. employee and department. When
I have two tables one Employee and mailing Subscriptions Employee looks like this: Name
I have two tables Employee (EmpID, Name, UpdatedBy, UpdateDate) EmpContact (ContactID, Contact,EmpID) I am
I have two tables in my database as following: Employee Table: Username, Name, Job,
I have two tables. **Employee** EmpId NOT NULL (PK) Name NOT NULL OrgID NULL
I have two tables Employee and Department . I have joined with primary key
Hypothetically I have two tables Employee and Locations. Additionaly I have a view viewEmpLocation

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.