开发者

How to obtain the result by using only 1 query?

I have a table containing IP Address,timestamp and browser columns.I need to find th开发者_C百科e percentage usage of a browser within past 1 week. How do I do it in a single query using nesting? No,it is not a homework question. I just can't seem to figure it out.


Using two inline views. One for the counts and one for the total.

Select 

    (bCounts.Broswer_counts * 100 / total.total) percentage,
    bCounts.broswer
FROM
(
     Select 
          Count(timestamp) broswer_counts, 
          browser
     From 
          table
     Where
           timestamp > '12/1/2010'
     Group by 
          Browser) bCounts,
 (SELECT COUNT(TimeStamp) total From Table WHERE timestamp > '12/1/2010') Total
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜