sql - MS Access Grouped Percentage Calculation -
not sure how best explain 1 have table example looks this:
date websitepage visits 01/01/2016 visits 50 01/01/2016 basket 40 01/01/2016 checkout 35 01/01/2016 thankyou 25 02/01/2016 visits 43 02/01/2016 basket 23 02/01/2016 checkout 20 02/01/2016 thankyou 12
as can see website pages (fictional example). want create query, access query calculation or sql or vba (limited cant use case statement in access sql), calculate websitepage conversion percentage e.g basket/checkout, checkout/thankyou , visits conversion of thankyou/visits etc.
i'm struggling how compile query or write calculation. simple in excel typically. dont want split websitepage out separate columns.
can point me in right direction?
you use query 4 different counts in 4 different columns make task easier:
select [date], sum(iif(websitepage = "visits", visits, 0)) visits, sum(iif(websitepage = "basket", visits, 0)) basket, sum(iif(websitepage = "checkout", visits, 0)) checkout, sum(iif(websitepage = "thankyou", visits, 0)) thankyou mytable group [date]
note iif
can solve issues use case when
expressions in more iso-compliant sql databases.
if save above statement query in ms access (let's call myquery), can things this:
select [date], 100*basket/checkout basket_checkout_pct, 100*checkout/thankyou checkout_thankyou_pct, 100*thankyou/visits thankyou_visits_pct myquery
Comments
Post a Comment