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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:52:15+00:00 2026-05-27T17:52:15+00:00

Here is the concept of what I am trying to do. I basically have

  • 0

Here is the concept of what I am trying to do.

I basically have two sets of data, one for the current info and one for archived info. I need to union them to show them all in one list.

My query is much more complicated than this but for simplicities sake I’ve just posted the general idea of what I need to do.

How would I get this to work for me? Any help is greatly appreciated.

(
    with m1 as 
    (
        select --distinct 
        pfa.FacilityID
        from PatientFormCompleted
    )
    select * from m1
    left join other tables
)
union all
(
    with m1archive as 
    (
        select --distinct 
        pfa.FacilityID
        from PatientFormArchive
    )
    select * from m1archive
    left join other tables
)
  • 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-27T17:52:15+00:00Added an answer on May 27, 2026 at 5:52 pm

    Likely this will be closed (voted, not downvoted, myself BTW) but after your edit, you did put some effort in the question, so here goes

    You can use multiple CTE‘s but with the constraint that

    • they follow one another
    • only the first WITH gets written

    Please note that you should not use SELECT * but be specific in what columns you’d like to return.

    SQL Statement

    with m1 as 
    (
        select --distinct 
        pfa.FacilityID
        from PatientFormCompleted
    )
    , m1archive as 
    (
        select --distinct 
        pfa.FacilityID
        from PatientFormArchive
    )
    select * from m1
    left join other tables
    union all
    select * from m1archive
    left join other tables
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if I'm missing a fairly fundamental concept here, but I'm trying to work
So here's the concept. I'm trying to write a C# backend for CouchDB (keep
I'm trying a little concept test to change one of the features of the
I have been trying to understand the MapReduce concept and apply it to my
This is basically javascript problem I am trying to get data by Ajax and
I'm trying to understand the concept of Algorithms and basically how they improve performance
I was creating a simple accordion menu based on concept used in here http://jsfiddle.net/WMfsR/
...at least, if the concept of an elegant workaround actually has merit! Here are
I believe my problem involves pointers, a concept I often struggle with, but here's
Yo community! might need some insights here.. :) I'm learning some more advance js-concepts.

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.