Sql查询电子商务解决方案的转换公式

时间:2012-01-20 11:56:52

标签: sql-server-2008 math stored-procedures select count

我需要一次性计算转换率,我可以获得计算的总计数值,以便用户在网站上取得全部成功:

SELECT COUNT(*) AS TotalSuccess FROM Orders Where Success like 'OK'

用户的全部内容可以找到:

SELECT COUNT(*) AS TotalTrialMade FROM productTrials

我如何能够成功地完成对话率,一次性使用sql,任何想法或帮助都将受到赞赏 感谢

1 个答案:

答案 0 :(得分:2)

SELECT TotalSuccess/TotalTrialMade AS ConversionRate FROM
(SELECT COUNT(*) AS TotalSuccess FROM Orders Where Success like 'OK') AS SuccessCount,
(SELECT COUNT(*) AS TotalTrialMade FROM productTrials) AS TrialCount