开发者

How to obtain the result by using only 1 query?

开发者 https://www.devze.com 2023-01-29 09:26 出处:网络
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,i

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

精彩评论

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

关注公众号