123sadsd's People
123sadsd's Issues
mid
select
MKABID,
FAMILY,
Number,
Date_Direction
from (
select MKABID,
FAMILY,
Number,
Date_Direction,
ROW_NUMBER() over (partition by MKABID order by Date_Direction desc) as rn
from hlt_MKAB m
join lbr_LaboratoryResearch lr
on lr.rf_MKABID = m.MKABID
) z
where MKABID > 0
and rn = 1
hard
select
MKABID,
FAMILY,
Number,
Date_Direction
from (
select MKABID,
FAMILY,
Number,
Date_Direction,
ROW_NUMBER() over (partition by MKABID order by Date_Direction desc) as rn
from hlt_MKAB m
join lbr_LaboratoryResearch lr
on lr.rf_MKABID = m.MKABID
) z
where MKABID > 0
and rn = 1
Nightmare
SELECT '[' + DepartmentCODE + '] ' + DepartmentNAME AS Department,
stt_MP.DateIngoing,
IsNull(CONVERT(varchar, Next_D.DateEnd, 104), '') AS DateEnd,
isNull(Diagnos, '') as Diagnos
FROM stt_MigrationPatient stt_MP
JOIN stt_StationarBranch stt_SB ON stt_MP.rf_StationarBranchID = stt_SB.StationarBranchID
JOIN oms_Department oms_D ON stt_SB.rf_DepartmentID = oms_D.DepartmentID
JOIN stt_MedicalHistory stt_MH ON stt_MP.rf_MedicalHistoryID = stt_MH.MedicalHistoryID
OUTER APPLY(
SELECT top 1 oms_MKB.DS + ' - ' + oms_MKB.NAME as Diagnos
FROM stt_Diagnos stt_DGNS
JOIN stt_DiagnosType stt_DT ON stt_DGNS.rf_DiagnosTypeID = stt_DT.DiagnosTypeID AND stt_DT.Code = '03'
JOIN oms_MKB ON oms_MKB.MKBID = stt_DGNS.rf_MKBID
WHERE stt_MP.MigrationPatientID = stt_DGNS.rf_MigrationPatientID
ORDER BY stt_DGNS.DiagnosID) DGNS
OUTER APPLY(
SELECT top 1 DateIngoing AS DateEnd
FROM stt_MigrationPatient stt_MP_NEXT
WHERE stt_MP_NEXT.DateIngoing > stt_MP.DateIngoing AND stt_MP_NEXT.rf_MedicalHistoryID = stt_MP.rf_MedicalHistoryID
ORDER BY DateIngoing) Next_D
WHERE stt_MP.rf_MedicalHistoryID = '999'
ORDER BY DateIngoing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.