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

  • Home
  • SEARCH
  • 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 8217027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:20:25+00:00 2026-06-07T12:20:25+00:00

I am joining some tables on a certain criteria. I would like to know

  • 0

I am joining some tables on a certain criteria. I would like to know if it’s possible to also display the count of those records that were excluded from the join?

my query:

SELECT...

FROM         dbo.QuickLabDump 
             ...

             left outer join hermes.lom.dbo.lom_specimen Lom
              on QuickLabDump.[specimen id] = lom.specimen
              LEFT outer join SalesDWH.dbo.Isomers Isomers
              on QuickLabDump.[specimen id] = Isomers.[accession id]



WHERE     lom.specimen is null
              and isomers.[accession id] is null...

as you can see i have two left outer joins.

in addition to the results of this query, i also want to return the count of those records from hermes.lom.dbo.lom_specimen and SalesDWH.dbo.Isomers that were excluded.

how do i get the counts of the excluded fields ?

here is the full query:

USE [SalesDWH]
GO

/****** Object:  View [dbo].[TurnAround]    Script Date: 07/10/2012 20:46:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO






ALTER VIEW [dbo].[TurnAround]
AS
SELECT     dbo.QuickLabDump.[Specimen ID], DATEPART(yyyy, dbo.QuickLabDump.[Date Entered]) AS [Year Entered],
DATEPART(yyyy, dbo.QuickLabDump.[Date Completed]) AS [year completed],

 CAST(CAST(dbo.QuickLabDump.[Date Entered] AS DATE) 
                      AS DATETIME) + CAST(dbo.QuickLabDump.[Time Entered] AS TIME) AS [DateTime Entered], CAST(CAST(dbo.QuickLabDump.[Date Completed] AS DATE) AS DATETIME) 
                      + CAST(dbo.QuickLabDump.[Time Completed] AS TIME) AS [DateTime Completed], dbo.QuickLabDump.[Practice Code] AS [QL Practuce Code], 
                      dbo.QLMLISMapping.[MLIS Practice ID], DATEPART(m, dbo.QuickLabDump.[Date Entered]) AS [Month Entered], 
                      DATEPART(m, dbo.QuickLabDump.[Date Completed]) AS [Month Completed],
                      ROUND(CAST(DATEDIFF(mi, 
                      CAST(CAST(dbo.QuickLabDump.[Date Entered] AS DATE) AS DATETIME) + CAST(dbo.QuickLabDump.[Time Entered] AS TIME), 
                      CAST(CAST(dbo.QuickLabDump.[Date Completed] AS DATE) AS DATETIME) + CAST(dbo.QuickLabDump.[Time Completed] AS TIME)) AS FLOAT) / 60, 0) AS TAT, 
                      ROUND(CAST(DATEDIFF(mi, CAST(CAST(dbo.QuickLabDump.[Date Entered] AS DATE) AS DATETIME) + CAST('9:00AM' AS TIME), 


                      CAST(CAST(dbo.QuickLabDump.[Date Completed] AS DATE) AS DATETIME) 
                      + CAST(dbo.QuickLabDump.[Time Completed] AS TIME)) AS float) / 60, 0) 

                      AS [Hours TurnAround Since 9AM], TAT9AMStateAdjusted=                   



                      ROUND(CAST(DATEDIFF(mi, CAST(CAST(dbo.QuickLabDump.[Date Entered] AS DATE) AS DATETIME) 
                      + CAST('9:00AM' AS TIME),                                            
                      CAST(CAST(dbo.QuickLabDump.[Date Completed] AS DATE) AS DATETIME) 
                      + CAST(dbo.QuickLabDump.[Time Completed] AS TIME)) AS float) / 60, 0)                         


                      +dbo.adjustedtime.timedifference
                      ,dbo.QuickLabDump.[Order Count], CONVERT(VARCHAR(8), DATEADD(D, - (1 * DATEPART(dw, dbo.QuickLabDump.[Date Entered])) + 6,
                       dbo.QuickLabDump.[Date Entered]), 1) AS [Week Ending]
FROM         dbo.QuickLabDump 
             INNER JOIN dbo.QLMLISMapping 
             ON dbo.QuickLabDump.[Practice Code] = dbo.QLMLISMapping.[Quicklab ID]
             left outer join dbo.AccountState
             on dbo.QuickLabDump.[Practice Code]=dbo.AccountState.[Account]
             left outer join dbo.AdjustedTime 
             ON dbo.AccountState.[state]=dbo.adjustedtime.[state]

             left outer join hermes.lom.dbo.lom_specimen Lom
              on QuickLabDump.[specimen id] = lom.specimen
              LEFT outer join SalesDWH.dbo.Isomers Isomers
              on QuickLabDump.[specimen id] = Isomers.[accession id]



WHERE     lom.specimen is null
              and isomers.[accession id] is null

              and (dbo.QuickLabDump.[Practice Code] NOT LIKE 'test%') 
              AND (dbo.QuickLabDump.[Specimen ID] NOT LIKE 'of%') 
              AND (dbo.QuickLabDump.Outcome <> 'rejected')
GROUP BY dbo.QuickLabDump.[Specimen ID], dbo.QuickLabDump.[Date Entered], dbo.QuickLabDump.[Time Entered], dbo.QuickLabDump.[Date Completed], 
                      dbo.QuickLabDump.[Time Completed], dbo.QuickLabDump.[Practice Name], dbo.QuickLabDump.[Practice Code], dbo.QuickLabDump.[Order Count], 
                      dbo.QLMLISMapping.[MLIS Practice ID],dbo.adjustedtime.timedifference
HAVING      (dbo.QuickLabDump.[Order Count] = MAX(dbo.QuickLabDump.[Order Count])) OR
                      (dbo.QuickLabDump.[Order Count] IS NULL)






GO
  • 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-07T12:20:26+00:00Added an answer on June 7, 2026 at 12:20 pm

    Are you looking for this?

    SELECT      ...,
                (
                  SELECT COUNt(*) FROM hermes.lom.dbo.lom_specimen WHERE specimen = lom.specimen
                 ) AS ColCount
    
    FROM         dbo.QuickLabDump    
                 left outer join hermes.lom.dbo.lom_specimen Lom   
                  on QuickLabDump.[specimen id] = lom.specimen   
                  LEFT outer join SalesDWH.dbo.Isomers Isomers   
                  on QuickLabDump.[specimen id] = Isomers.[accession id]   
    WHERE     lom.specimen is null   
                  and isomers.[accession id] is null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help joining these two tables I have two views that looks like
I have some tables that I'm joining in a query with Postgres (9). However,
I have 2 tables, one that holds records with some data related to it
How would I get a query that joins these four tables, and also gives
Im having some trouble with joining two tables. This is what my two tables
I am joining two tables 'sales/order_item_collection' and 'sales/orders' by 'order_id', so that afterward i
i'm joining tables like: select * from tableA a full join tableB b on
I'm currently building an app that contains around 60 or so tables, some with
I have a bunch of tables that I'm joining in a view. I need
I am joining some three tables and getting the following values week_num provision difference

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.