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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:56:04+00:00 2026-06-01T19:56:04+00:00

I have the following query:- select dbo.table1.service, dbo.table1.level_3_structure, Sum(table1.Reduced) as Total_Reduced from dbo.table1 where

  • 0

I have the following query:-

select
dbo.table1.service,
dbo.table1.level_3_structure,
Sum(table1.Reduced) as Total_Reduced

from dbo.table1

where 
dbo.table1.Period = 'Cumulative'

Group by 
dbo.table1.service,
dbo.table1.level_3_structure

Which results in something similar to this:-

service          level_3_structure   Total_Reduced
Service 1            Structure1          11.76
Service 2            Structure2         239.86
Service 3            Structure3         940.29

I have another table (table 2) which contains values service and level_3_structure and also contains a column called ‘FTE’.

What I want to do, is join onto this table based on service and level_3_structure and return a sum of the FTE.

I have tried the below query, but it seems to duplicate table1 for each maching row, resulting in around 8.3 million results.

select
dbo.table1.service,
dbo.table1.level_3_structure,
Sum(dbo.table1.Reduced) as Total_Reduced,
Sum(dbo.table2.fte) as 'Total FTE'

from dbo.table1
left join dbo.table2
on dbo.table1.service = dbo.table2.service and
   dbo.table1.level_3_structure = dbo.table2.level_3_structure

where 
dbo.table1.Period = 'Cumulative'

Group by 
dbo.table1.service,
dbo.table1.level_3_structure
  • 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-01T19:56:06+00:00Added an answer on June 1, 2026 at 7:56 pm

    If your first query returns the rows you need, then you could join that (and not table1) to table2:

    select service, level_3_structure, Total_Reduced, sum(fte) as Total_FTE
    from (
        select 
        dbo.table1.service, 
        dbo.table1.level_3_structure, 
        Sum(table1.Reduced) as Total_Reduced 
    
        from dbo.table1 
    
        where  
        dbo.table1.Period = 'Cumulative' 
    
        Group by  
        dbo.table1.service, 
        dbo.table1.level_3_structure 
    ) t1
    inner join table2 on t1.service = table2.service 
    AND t1.level_3_structure = table2.level_3_structure 
    
        Group by  
        dbo.table1.service, 
        dbo.table1.level_3_structure 
    

    Still, it sounds like your table1 should have the column fte.

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

Sidebar

Related Questions

I have the following query in sql: SELECT a1 FROM dbo.myProductNames WHERE keycode =
I have the following query. UPDATE t SET UnitsSold = sub.UnitsSold, FROM dbo.table1 t
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
I have the following query: SELECT item.`ID`, item.`Name`, item.`UnitCost`, item.`Price`, discount.`rate` FROM item INNER
I have the following query: SELECT * FROM table_name WHERE (col_1 LIKE '%$keyword%' OR
I have the following query: SELECT * FROM ( `teams` ) WHERE `name` =
I have the following query SELECT e.topicShortName, d.catalogFileID, e.topicID FROM catalog_topics a LEFT JOIN
I have the following query: SELECT COUNT(*) FROM FirstTable ft INNER JOIN SecondTable st
I have the following query: SELECT o.id,o.name FROM object o WHERE ( o.description LIKE
I have the following query SELECT * FROM attend RIGHT OUTER JOIN noattend ON

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.