What is this SQL Code doing?

Can someone tell me what "umc" is referencing, or how it is being populated in this query.  
I have a basic understanding of the #temp for temp tables but I am a bit puzzled with what is going on with "umc".
moriniaAdvanced Analytics AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Basically they have just called the larger query below UMC. It is just an alias for the query it is the equivalent of OH in the below query:
select * from orderheader as OH

Your query:
  mc.member_id, mc.enrollment_date , mc.exit_date
, mc.primary_secondary , mc.active_code , mc.benefit_plan
, mc.benefit_product, mc.benefit_group, 'CURR' as ONFILE
from llm.llmdba.member_coverage mc (nolock)
   , #mbrLkup m (nolock)
   mc.enrollment_date < '01/01/2012'
  and (mc.exit_date >= '01/01/2011' or mc.exit_date is null)
  and (convert(varchar(10),mc.enrollment_date,120) <> convert(varchar(10),mc.exit_date,120) or mc.exit_date is null)
  and mc.member_id = m.member_id
  mc.member_id, mc.enrollment_date, mc.exit_date, mc.primary_secondary
, mc.active_code, mc.benefit_plan, mc.benefit_product, mc.benefit_group, 'HIST' as ONFILE
from llm.llmdba.member_coverage_history mc (nolock), #mbrLkup m (nolock)
      mc.enrollment_date < '01/01/2012'  and (mc.exit_date > '01/01/2011' or mc.exit_date is null)
  and (convert(varchar(10),mc.enrollment_date,120) <> convert(varchar(10),mc.exit_date,120) or mc.exit_date is null)
  and mc.member_id = m.member_id
) umc

Hope that helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Paul JacksonSoftware EngineerCommented:
umc is referencing the results of the sub-select that starts on line 40 and finishes on line 86:

into #mbr_covg0
(     <------    starts here
) umc    <-- finishes here
moriniaAdvanced Analytics AnalystAuthor Commented:
SELECT umc.*
, dense_rank()
       over (partition by umc.member_id
             order by umc.enrollment_date desc
                    , umc.exit_date)
       as nRank

What is the first six lines of the code doing?
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

select umc.*
selects all the fields from UMC subquery as said above

Ranks the results per each umc.member_id with the most recent enrollment date and the earliest exit date being the highest ranked.

Have a read of this link on
Ranking Functions it should help you understand the dense_rank function a bit better.
moriniaAdvanced Analytics AnalystAuthor Commented:
The use of temporary tables and partitions is this regular SQL or Transact-Sql?  Since you are able to access temproary tables as well as the tables on the server what differentiates this code from regular  MSSql code?
Yes they get used quite a lot in TSQL soryr mate not sure what you mean by regular SQL.

This is valid MSSQL(TSQL) code, copying it into Sql Server Management Studio and performing a syntax check runs fine, so it is likely valid.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.