Home > database >  How to use SQL to query to each query gestational age is not the same
How to use SQL to query to each query gestational age is not the same

Time:11-12

According to the last period of time how many days to calculate how many weeks pregnant
For example,
DECLARE @ dt datetime
The SET @ dt=GETDATE ()
DECLARE @ number int
The SET @ number=3
SELECT the tm. YTXM TXM, vx. XM QZ_XM, vx. SFZJHM ZJHM, vx. LXDHHM LXDH,
Nx. XM ZF_XM, (SELECT COUNT (YLZD6) FROM TB_CQ_YF_CQTJXX WHERE tj. SJRBH=' ') as CQJCCS,
Sc. SCJGMC SCJG, pg. PGJBMC PGJB, gg. MCYJRQ MCYJ,
Gg. TJRQ DATEADD (Day, @ number - (DATEPART (Weekday, @ dt) + @ @ DATEFIRST - 1) % 7, @ dt) JDYZ,

* from TB_UP_JT_JTDADJ jt
Left the join TB_RYJBXXB nx on jt. JTDAH=nx. JTDAH
Left the join TB_RYJBXXB vx on jt. JTDAH=vx. JTDAH
LEFT the JOIN TB_PU_CQ_GGXX gg on gg. JTDAH=jt. JTDAH
LEFT the JOIN TB_PU_YF_TM_TXMXX tm on the tm. FNBH=vx. GRDABH
LEFT the JOIN TB_CQ_YF_CQTJXX tj on tj. SJRBH=vx. GRDABH
LEFT the JOIN TB_CQ_YF_FX_GWSCXX sc on sc. SCRBH=vx. GRDABH
LEFT the JOIN TB_CQ_YF_FX_GWPGXX pg on pg. JSPGRBH=vx. GRDABH
Left the JOIN TB_YF_CS_CSFMJL cs on cs. FNBH=vx. GRDABH
LEFT the JOIN TB_YF_JAXX ja on ja. JSZZRBH=vx. GRDABH
Where 1=1 AND nx. GRSFBH=1 AND vx. GRSFBH=2 AND vx. BJ=1

CodePudding user response:

DECLARE @ dt datetime
The SET @ dt=GETDATE ()
DECLARE @ number int
The SET @ number=3
SELECT the tm. YTXM TXM, vx. XM QZ_XM, vx. SFZJHM ZJHM, vx. LXDHHM LXDH,
Nx. XM ZF_XM, (SELECT COUNT (YLZD6) FROM TB_CQ_YF_CQTJXX WHERE tj. SJRBH=' ') as CQJCCS,
Sc. SCJGMC SCJG, pg. PGJBMC PGJB, gg. MCYJRQ MCYJ,
Gg. TJRQ DATEADD (Day, @ number - (DATEPART (Weekday, @ dt) + @ @ DATEFIRST - 1) % 7, @ dt) JDYZ,

* from TB_UP_JT_JTDADJ jt
Left the join TB_RYJBXXB nx on jt. JTDAH=nx. JTDAH
Left the join TB_RYJBXXB vx on jt. JTDAH=vx. JTDAH
LEFT the JOIN TB_PU_CQ_GGXX gg on gg. JTDAH=jt. JTDAH
LEFT the JOIN TB_PU_YF_TM_TXMXX tm on the tm. FNBH=vx. GRDABH
LEFT the JOIN TB_CQ_YF_CQTJXX tj on tj. SJRBH=vx. GRDABH
LEFT the JOIN TB_CQ_YF_FX_GWSCXX sc on sc. SCRBH=vx. GRDABH
LEFT the JOIN TB_CQ_YF_FX_GWPGXX pg on pg. JSPGRBH=vx. GRDABH
Left the JOIN TB_YF_CS_CSFMJL cs on cs. FNBH=vx. GRDABH
LEFT the JOIN TB_YF_JAXX ja on ja. JSZZRBH=vx. GRDABH
Where 1=1 AND nx. GRSFBH=1 AND vx. GRSFBH=2 AND vx. BJ=1
  • Related