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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:53:43+00:00 2026-06-03T12:53:43+00:00

I have a View that is pretty complex. The query pulls data from about

  • 0

I have a View that is pretty complex. The query pulls data from about 14 tables with a subquery involved also. The results are as follows:
[Unique Identifier][office][number][description][value][customer][strjobid]…

Now this information is pulled from a View called ViewTeamMembers. The ViewTeamMembers view will return all team members per a unique identifier. There are times when there are team members but there is no “Owner”. I need my query to pull the data from ViewTeamMembers (Which is is doing now) and check if there is an owner. If there is not an owner, I need to insert a row into my result set where the owner name would be “Not Assigned” and all of the other data would be populated by the data from the other team members. How can I get this accomplished?

Example:

ViewTeamMembers
[unique123][Office1][555-5555][description][1,000][Frank][hourly]
[unique123][Office1][555-5555][description][1,000][Tom][Salary]
[unique123][Office1][555-5555][description][1,000][Brent][Hourly]

I need to query against that and see if there is a row that exists that has someone with the jobid “Owner” and if not, I need to insert my own row into my view with

[unique123][Office1][555-5555][description][1,000][Not Assigned][Owner]

so when I view my query result set I should get

[unique123][Office1][555-5555][description][1,000][Frank][hourly]
[unique123][Office1][555-5555][description][1,000][Tom][Salary]
[unique123][Office1][555-5555][description][1,000][Brent][Hourly]
[unique123][Office1][555-5555][description][1,000][Not Assigned][Owner]

This is my join

LEFT OUTER JOIN
dbo.viewteammembers ON dbo.viewteammembers.guidrequirementid = dbo.tblrequirements.guidrequirementid

I would assume I would have to do something like this:

select * from viewteammembers case when not exists(select * from viewteammebers where strjobid = 'Owner') then 

but I don’t know what the syntax is to make this work.

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-06-03T12:53:45+00:00Added an answer on June 3, 2026 at 12:53 pm

    Depending on the type of database you use there might be nicer ways to do this but something like this should do the trick

       -- get dummy rows for all distinct identifiers that don't already have an owner
        select 
           distinct [Unique Identifier], [office], [number], [description], 
           1 as value, 
           'Not Assigned' as Customer, 
           'Owner' as strjobid from ViewTeamMembers vtm
        where 
           not exists (select 1 from ViewTeamMembers vtm2 
                       where vtm2.[Unique Identifier] = vtm.[Unique Identifier] 
                       and StrJobId = 'Owner')
        union all -- add everything already there
        select 
           [Unique Identifier], [office], [number], [description],
           [value], [customer], [strjobid]
        from ViewTeamMembers
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that takes data from my site and then makes it
I have a view that I would like to populate data when the next
I have a View that inherits from LinearLayout that inflates itself. After it has
I will have to implement a calendar view/controller that looks pretty much like the
I have a view that loads a partial view from a controller action using
I have a set of pretty complex forms that I'd like to implement in
I have a pretty complex PHP/HTML view. However, I recently changed my site to
I am beginner in rails. I have view that i try to print inside
I have a view that is loaded in the MainWindow.xib. It is just a
I have a view that I want to be converted into JSON. What is

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.