|
|
|
@ -1373,25 +1373,20 @@
|
|
|
|
|
,0 AS dqi_food_11
|
|
|
|
|
,0 AS dqi_food_12
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT t.dn_no
|
|
|
|
|
,b.weight
|
|
|
|
|
,t.eat_qty
|
|
|
|
|
,t.reg_dt
|
|
|
|
|
FROM tbl_bf_daily_nutrition_1 t
|
|
|
|
|
left join tbl_bf_growth_body b
|
|
|
|
|
on t.smc_no = b.smc_no
|
|
|
|
|
and (DATE(t.reg_dt) = DATE(b.reg_dt)
|
|
|
|
|
or DATE(b.reg_dt) = (
|
|
|
|
|
select DATE(max(reg_dt)) from tbl_bf_growth_body m
|
|
|
|
|
where m.smc_no = #smc_no#
|
|
|
|
|
))
|
|
|
|
|
WHERE t.smc_no= #smc_no#
|
|
|
|
|
SELECT dn_no
|
|
|
|
|
,weight
|
|
|
|
|
,eat_qty
|
|
|
|
|
,srv
|
|
|
|
|
,rem
|
|
|
|
|
,reg_dt
|
|
|
|
|
FROM tbl_bf_daily_nutrition_1
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
<!-- AND weight<![CDATA[>]]>0 -->
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(t.reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(t.reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(t.reg_dt),"/",WEEK(t.reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(t.reg_dt),"/",MONTH(t.reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(reg_dt),"/",WEEK(reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(reg_dt),"/",MONTH(reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
</isNotEmpty>
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_milk_nutirition2 dn2 ON 1=1
|
|
|
|
@ -1435,27 +1430,20 @@
|
|
|
|
|
,hb.dhb_cd
|
|
|
|
|
,hb.name
|
|
|
|
|
FROM(
|
|
|
|
|
SELECT t.dn_no
|
|
|
|
|
,t.db_dhb_no
|
|
|
|
|
,t.reg_dt
|
|
|
|
|
,b.weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_9 t
|
|
|
|
|
left join tbl_bf_growth_body b
|
|
|
|
|
on t.smc_no = b.smc_no
|
|
|
|
|
and (DATE(t.reg_dt) = DATE(b.reg_dt)
|
|
|
|
|
or DATE(b.reg_dt) = (
|
|
|
|
|
select DATE(max(reg_dt)) from tbl_bf_growth_body m
|
|
|
|
|
where m.smc_no = #smc_no#
|
|
|
|
|
))
|
|
|
|
|
WHERE t.smc_no=#smc_no#
|
|
|
|
|
AND t.db_dhb_no IS NOT NULL
|
|
|
|
|
AND t.db_dhb_tp ='bf'
|
|
|
|
|
SELECT dn_no
|
|
|
|
|
,db_dhb_no
|
|
|
|
|
,reg_dt
|
|
|
|
|
,weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_9
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
AND db_dhb_no IS NOT NULL
|
|
|
|
|
AND db_dhb_tp ='bf'
|
|
|
|
|
<!-- AND weight<![CDATA[>]]>0 -->
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(t.reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(t.reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(t.reg_dt),"/",WEEK(t.reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(t.reg_dt),"/",MONTH(t.reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(reg_dt),"/",WEEK(reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(reg_dt),"/",MONTH(reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
</isNotEmpty>
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_home_bf hb ON hb.dhb_no = x.db_dhb_no
|
|
|
|
@ -1506,27 +1494,20 @@
|
|
|
|
|
,hb.dhb_no
|
|
|
|
|
,hb.name
|
|
|
|
|
FROM(
|
|
|
|
|
SELECT t.dn_no
|
|
|
|
|
,t.db_dhb_no
|
|
|
|
|
,t.reg_dt
|
|
|
|
|
,b.weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_9 t
|
|
|
|
|
left join tbl_bf_growth_body b
|
|
|
|
|
on t.smc_no = b.smc_no
|
|
|
|
|
and (DATE(t.reg_dt) = DATE(b.reg_dt)
|
|
|
|
|
or DATE(b.reg_dt) = (
|
|
|
|
|
select DATE(max(reg_dt)) from tbl_bf_growth_body m
|
|
|
|
|
where m.smc_no = #smc_no#
|
|
|
|
|
))
|
|
|
|
|
WHERE t.smc_no=#smc_no#
|
|
|
|
|
AND t.db_dhb_no IS NOT NULL
|
|
|
|
|
AND t.db_dhb_tp ='sf'
|
|
|
|
|
SELECT dn_no
|
|
|
|
|
,db_dhb_no
|
|
|
|
|
,reg_dt
|
|
|
|
|
,weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_9
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
AND db_dhb_no IS NOT NULL
|
|
|
|
|
AND db_dhb_tp ='sf'
|
|
|
|
|
<!-- AND weight<![CDATA[>]]>0 -->
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(t.reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(t.reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(t.reg_dt),"/",WEEK(t.reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(t.reg_dt),"/",MONTH(t.reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(reg_dt),"/",WEEK(reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(reg_dt),"/",MONTH(reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
</isNotEmpty>
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_home_sf hb ON hb.dhb_no = x.db_dhb_no
|
|
|
|
@ -1572,27 +1553,20 @@
|
|
|
|
|
,IF(dbc.dqi_food_11 IS NULL, 0, ROUND(dbc.dqi_food_11*x.weight,2)) AS dqi_food_11
|
|
|
|
|
,IF(dbc.dqi_food_12 IS NULL, 0, ROUND(dbc.dqi_food_12*x.weight,2)) AS dqi_food_12
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT t.dn_no
|
|
|
|
|
,t.db_dbc_no
|
|
|
|
|
,t.reg_dt
|
|
|
|
|
,b.weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_10 t
|
|
|
|
|
left join tbl_bf_growth_body b
|
|
|
|
|
on t.smc_no = b.smc_no
|
|
|
|
|
and (DATE(t.reg_dt) = DATE(b.reg_dt)
|
|
|
|
|
or DATE(b.reg_dt) = (
|
|
|
|
|
select DATE(max(reg_dt)) from tbl_bf_growth_body m
|
|
|
|
|
where m.smc_no = #smc_no#
|
|
|
|
|
))
|
|
|
|
|
WHERE t.smc_no=#smc_no#
|
|
|
|
|
AND t.db_dbc_no IS NOT NULL
|
|
|
|
|
AND t.db_dbc_tp ='bf'
|
|
|
|
|
SELECT dn_no
|
|
|
|
|
,db_dbc_no
|
|
|
|
|
,reg_dt
|
|
|
|
|
,weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_10
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
AND db_dbc_no IS NOT NULL
|
|
|
|
|
AND db_dbc_tp ='bf'
|
|
|
|
|
<!-- AND t.weight<![CDATA[>]]>0 -->
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(t.reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(t.reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(t.reg_dt),"/",WEEK(t.reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(t.reg_dt),"/",MONTH(t.reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(reg_dt),"/",WEEK(reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(reg_dt),"/",MONTH(reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
</isNotEmpty>
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_bf_commerce dbc ON x.db_dbc_no=dbc.dbc_no
|
|
|
|
@ -1633,27 +1607,20 @@
|
|
|
|
|
,0 AS dqi_food_11
|
|
|
|
|
,0 AS dqi_food_12
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT t.dn_no
|
|
|
|
|
,t.db_dbc_no
|
|
|
|
|
,t.reg_dt
|
|
|
|
|
,b.weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_10 t
|
|
|
|
|
left join tbl_bf_growth_body b
|
|
|
|
|
on t.smc_no = b.smc_no
|
|
|
|
|
and (DATE(t.reg_dt) = DATE(b.reg_dt)
|
|
|
|
|
or DATE(b.reg_dt) = (
|
|
|
|
|
select DATE(max(reg_dt)) from tbl_bf_growth_body m
|
|
|
|
|
where m.smc_no = #smc_no#
|
|
|
|
|
))
|
|
|
|
|
WHERE t.smc_no=#smc_no#
|
|
|
|
|
AND t.db_dbc_no IS NOT NULL
|
|
|
|
|
AND t.db_dbc_tp ='sf'
|
|
|
|
|
SELECT dn_no
|
|
|
|
|
,db_dbc_no
|
|
|
|
|
,reg_dt
|
|
|
|
|
,weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_10
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
AND db_dbc_no IS NOT NULL
|
|
|
|
|
AND db_dbc_tp ='sf'
|
|
|
|
|
<!-- AND t.weight<![CDATA[>]]>0 -->
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(t.reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(t.reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(t.reg_dt),"/",WEEK(t.reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(t.reg_dt),"/",MONTH(t.reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(reg_dt),"/",WEEK(reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(reg_dt),"/",MONTH(reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
</isNotEmpty>
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_sf_commerce dbc ON x.db_dbc_no=dbc.dbc_no
|
|
|
|
@ -1694,27 +1661,20 @@
|
|
|
|
|
,IF(STRCMP('당함유제품', dn.dqi_cate), 0, ROUND(dn.srv*x.weight,2)) AS dqi_food_11
|
|
|
|
|
,IF(STRCMP('짠과자', dn.dqi_cate), 0, ROUND(dn.srv*x.weight,2)) AS dqi_food_12
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT t.dn_no
|
|
|
|
|
,t.db_dn_no
|
|
|
|
|
,t.reg_dt
|
|
|
|
|
,b.weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_3 t
|
|
|
|
|
left join tbl_bf_growth_body b
|
|
|
|
|
on t.smc_no = b.smc_no
|
|
|
|
|
and (DATE(t.reg_dt) = DATE(b.reg_dt)
|
|
|
|
|
or DATE(b.reg_dt) = (
|
|
|
|
|
select DATE(max(reg_dt)) from tbl_bf_growth_body m
|
|
|
|
|
where m.smc_no = #smc_no#
|
|
|
|
|
))
|
|
|
|
|
WHERE t.smc_no=#smc_no#
|
|
|
|
|
AND t.db_dn_no IS NOT NULL
|
|
|
|
|
AND t.db_dn_tp ='bf'
|
|
|
|
|
SELECT dn_no
|
|
|
|
|
,db_dn_no
|
|
|
|
|
,reg_dt
|
|
|
|
|
,weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_3
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
AND db_dn_no IS NOT NULL
|
|
|
|
|
AND db_dn_tp ='bf'
|
|
|
|
|
<!-- AND weight<![CDATA[>]]>0 -->
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(t.reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(t.reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(t.reg_dt),"/",WEEK(t.reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(t.reg_dt),"/",MONTH(t.reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(reg_dt),"/",WEEK(reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(reg_dt),"/",MONTH(reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
</isNotEmpty>
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_nutrient dn ON x.db_dn_no=dn.dn_no
|
|
|
|
@ -1754,27 +1714,20 @@
|
|
|
|
|
,IF(dn.dairy = 'Y', ROUND(dn.srv*x.weight,2),0) AS dqi_food_11
|
|
|
|
|
,0 AS dqi_food_12
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT t.dn_no
|
|
|
|
|
,t.db_dn_no
|
|
|
|
|
,t.reg_dt
|
|
|
|
|
,nvl(b.weight,1) as weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_3 t
|
|
|
|
|
left join tbl_bf_growth_body b
|
|
|
|
|
on t.smc_no = b.smc_no
|
|
|
|
|
and (DATE(t.reg_dt) = DATE(b.reg_dt)
|
|
|
|
|
or DATE(b.reg_dt) = (
|
|
|
|
|
select DATE(max(reg_dt)) from tbl_bf_growth_body m
|
|
|
|
|
where m.smc_no = #smc_no#
|
|
|
|
|
))
|
|
|
|
|
WHERE t.smc_no=#smc_no#
|
|
|
|
|
AND t.db_dn_no IS NOT NULL
|
|
|
|
|
AND T.db_dn_tp = 'sf'
|
|
|
|
|
SELECT dn_no
|
|
|
|
|
,db_dn_no
|
|
|
|
|
,reg_dt
|
|
|
|
|
,weight
|
|
|
|
|
FROM tbl_bf_daily_nutrition_3
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
AND db_dn_no IS NOT NULL
|
|
|
|
|
AND db_dn_tp ='sf'
|
|
|
|
|
<!-- AND weight<![CDATA[>]]>0 -->
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(t.reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(t.reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(t.reg_dt),"/",WEEK(t.reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(t.reg_dt),"/",MONTH(t.reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(reg_dt),"/",WEEK(reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(reg_dt),"/",MONTH(reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
</isNotEmpty>
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_sf_commerce dn ON x.db_dn_no=dn.dbc_no
|
|
|
|
@ -1802,7 +1755,7 @@
|
|
|
|
|
,ROUND(vitamine*weight,2) AS vitamine
|
|
|
|
|
,ROUND(zn*weight,2) AS zn
|
|
|
|
|
,0 AS dqi_food_1
|
|
|
|
|
,ROUND((eat_qty-rem)*weight,2) AS dqi_food_2
|
|
|
|
|
,ROUND(eat_qty,2) AS dqi_food_2
|
|
|
|
|
,0 AS dqi_food_3
|
|
|
|
|
,0 AS dqi_food_4
|
|
|
|
|
,0 AS dqi_food_5
|
|
|
|
@ -1818,12 +1771,13 @@
|
|
|
|
|
,db_dn_no
|
|
|
|
|
,nvl(eat_qty,0) eat_qty
|
|
|
|
|
,nvl(rem,0) as rem
|
|
|
|
|
,ROUND((nvl(eat_qty,0)-nvl(rem,0))/100,2) AS weight
|
|
|
|
|
,weight
|
|
|
|
|
,reg_dt
|
|
|
|
|
FROM tbl_bf_daily_nutrition_2
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
AND (nvl(eat_qty,0)-nvl(rem,0))<![CDATA[>]]>0
|
|
|
|
|
AND db_dn_no IS NOT NULL
|
|
|
|
|
<!-- AND db_dn_no IS NOT NULL -->
|
|
|
|
|
AND milk_tp = 87
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
@ -1833,6 +1787,62 @@
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_nutrient dn ON x.db_dn_no = dn.dn_no
|
|
|
|
|
)
|
|
|
|
|
UNION ALL
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
x.reg_dt ,
|
|
|
|
|
ROUND(dn2.enerc * weight, 2) as enerc ,
|
|
|
|
|
ROUND(dn2.chotdf * weight, 2) as chotdf ,
|
|
|
|
|
ROUND(dn2.procnp * weight, 2) as procnp ,
|
|
|
|
|
ROUND(dn2.fat * weight, 2) as fat ,
|
|
|
|
|
ROUND(dn2.sugar * weight, 2) as sugar ,
|
|
|
|
|
ROUND(dn2.fibtg * weight, 2) as fibtg ,
|
|
|
|
|
ROUND(dn2.na * weight, 2) as na ,
|
|
|
|
|
ROUND(dn2.thia * weight, 2) as vitaminb1 ,
|
|
|
|
|
ROUND(dn2.ribf * weight, 2) as vitaminb2 ,
|
|
|
|
|
ROUND(dn2.nia * weight, 2) as niacin ,
|
|
|
|
|
ROUND(dn2.ca * weight, 2) as ca ,
|
|
|
|
|
ROUND(dn2.k * weight, 2) as k ,
|
|
|
|
|
ROUND(dn2.fe * weight, 2) as fe ,
|
|
|
|
|
ROUND(dn2.vita * weight, 2) as vitamina ,
|
|
|
|
|
ROUND(dn2.vitc * weight, 2) as vitaminc ,
|
|
|
|
|
ROUND(dn2.vitd * weight, 2) as vitamind ,
|
|
|
|
|
ROUND(dn2.vite * weight, 2) as vitamine ,
|
|
|
|
|
ROUND(dn2.zn * weight, 2) as zn ,
|
|
|
|
|
ROUND(eat_qty, 2) as dqi_food_1 ,
|
|
|
|
|
0 as dqi_food_2 ,
|
|
|
|
|
0 as dqi_food_3 ,
|
|
|
|
|
0 as dqi_food_4 ,
|
|
|
|
|
0 as dqi_food_5 ,
|
|
|
|
|
0 as dqi_food_6 ,
|
|
|
|
|
0 as dqi_food_7 ,
|
|
|
|
|
0 as dqi_food_8 ,
|
|
|
|
|
0 as dqi_food_9 ,
|
|
|
|
|
0 as dqi_food_10 ,
|
|
|
|
|
0 as dqi_food_11 ,
|
|
|
|
|
0 as dqi_food_12
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
dn_no
|
|
|
|
|
,db_dn_no
|
|
|
|
|
,nvl(eat_qty,0) eat_qty
|
|
|
|
|
,nvl(rem,0) as rem
|
|
|
|
|
,weight
|
|
|
|
|
,reg_dt
|
|
|
|
|
FROM tbl_bf_daily_nutrition_2
|
|
|
|
|
WHERE smc_no=#smc_no#
|
|
|
|
|
AND (nvl(eat_qty,0)-nvl(rem,0))<![CDATA[>]]>0
|
|
|
|
|
<!-- AND db_dn_no IS NOT NULL -->
|
|
|
|
|
AND milk_tp = 88
|
|
|
|
|
<isNotEmpty property="scope">
|
|
|
|
|
<isEqual property="scope" compareValue="yday">AND DATE(reg_dt) = current_date()-interval 1 day</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="day">AND DATE(reg_dt)=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="week">AND CONCAT(YEAR(reg_dt),"/",WEEK(reg_dt))=#reg_dt#</isEqual>
|
|
|
|
|
<isEqual property="scope" compareValue="month">AND CONCAT(YEAR(reg_dt),"/",MONTH(reg_dt)) = #reg_dt#</isEqual>
|
|
|
|
|
</isNotEmpty>
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_db_milk_nutirition2 dn2 ON 1=1
|
|
|
|
|
)
|
|
|
|
|
)x
|
|
|
|
|
LEFT JOIN tbl_bf_family_baby bfb ON bfb.smc_no=#smc_no#
|
|
|
|
|
ORDER BY x.reg_dt DESC
|
|
|
|
|