Sql

Mallorie W.

asked • 03/18/24

Can anyone help me update a query to include open cases, as well as cases opened in the current year (it currently only pulls cases opened in the current year) and make the date dynamic?

Beginner here...


This is what I'm working with.


SELECT distinct [EventId]
,[EventFromDt] as 'Outreach From Date'
,[EventCloseDt] as 'Outreach Close Date'
,[EventSummaryTxt] as 'Outreach Program'
,[IssuerMemberId]
,[BirthDt] as 'Birth Date'
,[FirstNameTxt] as 'First Name'
,[LastNameTxt] as 'Last Name'
,[GenderTxt] as 'Gender'
,[AffiliationGroupCd] 'Master Group Number'
,[AffiliationGroupTxt] 'Master Group Name'
,cc.[GroupId]
,cc.[GroupLevel1Id]
,gp.GroupLevel1NameTxt as 'Group Name'
,[EventReviewTypeTxt] as 'Case Management Condition'
,[DiagnosisCd1]
,[DiagnosisTxt1]
,[DiagnosisCd2]
,[DiagnosisTxt2]
,[DiagnosisCd3]
,[DiagnosisTxt3]

FROM [edw].[vwMedicalManagementCaseMgmtandOutreachSummary] cc

left join edw.DimGroup gp
on gp.groupid = cc.groupid
and gp.GroupLevel1Id = cc.GroupLevel1Id
and gp.GroupLevel2Id = cc.GroupLevel2Id
and gp.GroupLevel3Id = cc.GroupLevel3Id

where AffiliationGroupCd = '10838'
and EventFromDt > '2022-12-31' --this will need updated to '2023-12-31' after 2/1/24
and validind = 'Y'



1 Expert Answer

By:

Tripp B. answered • 03/20/24

Tutor
5 (8)

I love sharing what I know and helping people achieve their goals

Tripp B.

you could also change your WHERE clause to only consider the year of the EventFromDt field. Something like YEAR(EventFromDt) = 2024. The exact function call you make to extract the year will depend on what database system you're using, but the basic idea will be the same for most relational database management systems.
Report

03/20/24

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.