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
精彩评论