Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dcobb
Yak Posting Veteran
76 Posts |
Posted - 2002-03-12 : 11:37:34
|
| Background: I have one table with one column (log_uristem) - taken from IIS LOGContents of log_uristem.../list_categories.asp/index.asp/list_categories.asp/otherpage.asp/andanother.asp/index.asp/list_categories.aspWhat I need to be able to do is sort all contents (both ways: ASC & DESC) based on occurance, e.g. what was the most accessed, what was the least accessed AND remove all duplicates.So the output would be for DESC:/list_categories.asp/index.asp/otherpage.asp/andanother.aspAny ideas?ThanksdC |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-03-12 : 11:45:45
|
| You Need GROUP BY. You want to group all of these URL's together, and then count the number of each you have right?CREATE TABLE #URL(log_uristem varchar(100))INSERT INTO #URL(log_uristem) values('/list_categories.asp')INSERT INTO #URL(log_uristem) values('/index.asp')INSERT INTO #URL(log_uristem) values('/otherpage.asp')INSERT INTO #URL(log_uristem) values('/andanother.asp')INSERT INTO #URL(log_uristem) values('/index.asp')INSERT INTO #URL(log_uristem) values('/list_categories.asp')INSERT INTO #URL(log_uristem) values('/list_categories.asp')INSERT INTO #URL(log_uristem) values('/list_categories.asp')INSERT INTO #URL(log_uristem) values('/otherpage.asp')SELECT log_uristem, Count(*) as NumOfOccurances FROM #URL GROUP BY log_uristem ORDER BY NumOfOccurancesSELECT log_uristem, Count(*) as NumOfOccurances FROM #URL GROUP BY log_uristem ORDER BY NumOfOccurances DESCDROP TABLE #URLMichael |
 |
|
|
dcobb
Yak Posting Veteran
76 Posts |
Posted - 2002-03-12 : 15:21:36
|
| Sounds good to me.Thank you.dC |
 |
|
|
|
|
|