| | |
| | | FROM |
| | | ( |
| | | SELECT |
| | | loc_no, |
| | | DISTINCT loc_no, |
| | | locd.matnr, |
| | | locd.maktx, |
| | | locd.owner, |
| | | locd.batch, |
| | | create_time, |
| | | locd.specs, |
| | | locd.unit, |
| | | inventory_max, |
| | | inventory_min, |
| | | inventory_age_max, |
| | | count_anfme, |
| | | DATEDIFF( DAY, create_time, GETDATE( ) ) AS [diff_time] |
| | | FROM |
| | | man_loc_detl locd |
| | |
| | | count_anfme |
| | | FROM |
| | | man_mat |
| | | RIGHT JOIN ( SELECT matnr, SUM ( anfme ) AS count_anfme FROM man_loc_detl loc GROUP BY matnr ) aa ON aa.matnr = man_mat.matnr |
| | | RIGHT JOIN ( SELECT matnr,batch,owner, SUM ( anfme ) AS count_anfme FROM man_loc_detl loc GROUP BY matnr,batch,owner ) aa ON aa.matnr = man_mat.matnr |
| | | ) warn ON locd.matnr = warn.matnr |
| | | WHERE |
| | | DATEDIFF( DAY, create_time, GETDATE( ) ) > inventory_age_max |