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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:40:35+00:00 2026-06-11T12:40:35+00:00

Hi I have a SQL server db, when I execute following query I get

  • 0

Hi I have a SQL server db, when I execute following query I get 4 results:

WITH MyCTE (ID, hasLead, SubgroupFk, SubTeamFk)
AS (
SELECT [ID],[hasLead],[SubgroupFk],[SubTeamFk]
FROM [LocalGTPDatabase].[dbo].[LinkProject-Area]
where [ProjectFk]=90
)
SELECT 
*
FROM MyCTE 
INNER JOIN EmplTeam ON EmplTeam.ID = MyCTE.SubTeamFk 
INNER JOIN [Department] ON [Department].ID = MyCTE.SubgroupFk

For every LinkProjectArea Id I have 1 Headcount item / year
Headcount table is connected with: LinkProjectAreaFk to previous mentioned table

So I thought I can combine the headcount with following query:

WITH MyCTE (ID, hasLead, SubgroupFk, SubTeamFk)
AS (
SELECT [ID],[hasLead],[SubgroupFk],[SubTeamFk]
FROM [LocalGTPDatabase].[dbo].[LinkProject-Area]
where [ProjectFk]=90
)
SELECT 
*
FROM MyCTE 
INNER JOIN EmplTeam ON EmplTeam.ID = MyCTE.SubTeamFk 
INNER JOIN [Department] ON [Department].ID = MyCTE.SubgroupFk 
INNER JOIN [HeadCount] ON [HeadCount].LinkProjectAreaFk = MyCTE.ID

But when I execute this query I get no results but every id of this query has a headcount. What am I doing wrong?
I really have no clue

  • 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-11T12:40:36+00:00Added an answer on June 11, 2026 at 12:40 pm

    If you get no error but just no data, there is probably no data.
    Maybe if there is a “HeadCount”Item, there is no Department-Item or there is no Empl-Team-Item that fits.

    Basically you have an and-Connection. Show all combinations of MyCTE, EmplTeam, Department and HeadCount, where ALL of your three “ON-Conditions” are valid.

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

Sidebar

Related Questions

I have a nested query which when I execute in SQL server 2008 management
I have the following query: SELECT MAX([LastModifiedTime]) FROM Workflow There are approximately 400M rows
I've got 2 servers running SQL Server 2008, and I have the following query:
I have an interesting case of results sets returned by SQL Server being different
I have a SELECT query that yields multiple results and do not have any
I am using VS2005 C# and SQL Server 2005. I have a SQL Query
I have this query: select top(2) property_id_ref ,image_file ,property_name from property_master a inner join
I have the following query: WITH cte AS ( SELECT windowId, frameIndx, elemIndx, comment,
I have the following lines of code: sql = source C:\\My Dropbox\\workspace\\projects\\hosted_inv\\create_site_db.sql cursor.execute (sql)
I have this query select * from openQuery(hades,select to_char(T$STDT,'dd-Mon-YYYY') stdt,to_char(T$TDAT,'dd-Mon-YYYY') tdat ,fdG2J(T$TDAT)-fdG2J(t$stdt) diff,T$DISC ,fdG2J(Sysdate)

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.