I'm trying to use a table 'oelinhst_sql' to calculate on time delivery. What I need it to do is count the number of records in the current month then count them again where the request date equals the shipping date then divide the count from where they match by the total number of records. This is what my query looks like right now...
select(select COUNT(line_seq_no) from oelinhst_sql where MONTH(GETDATE())=MONTH(shipped_dt) and YEAR(GETDATE())=YEAR(shipped_dt) and req_ship_dt=shipped_dt)/
(select COUNT(line_seq_no) from oelinhst_sql where MONTH(GETDATE())=MONTH(shipped_dt) and YEAR(GETDATE())=YEAR(shipped_dt))
However when I run it I either get 0 as the result, not the number it should be. Can someone tell me what I'm doing wrong? Thanks!
select(select COUNT(line_seq_no) from oelinhst_sql where MONTH(GETDATE())=MONTH(shipped_dt) and YEAR(GETDATE())=YEAR(shipped_dt) and req_ship_dt=shipped_dt)/
(select COUNT(line_seq_no) from oelinhst_sql where MONTH(GETDATE())=MONTH(shipped_dt) and YEAR(GETDATE())=YEAR(shipped_dt))
However when I run it I either get 0 as the result, not the number it should be. Can someone tell me what I'm doing wrong? Thanks!