| Author |
Topic |
|
fizgig
Starting Member
34 Posts |
Posted - 2001-12-14 : 04:04:57
|
| Hi there. I have a table where i register every page view on my website :id, articleid, moment (datetime field)The select statement i'm looking for should compose a list of pages visited by day. Got an idea? |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2001-12-14 : 05:04:24
|
| if u r looking for page on a specific daythis should help select id, articleid,moment from tablename where moment='14-dec-2001'am sure u r looking for something more, can u xplain more-------------------------"Success is when Preparedness meets Opportunity" |
 |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2001-12-14 : 05:33:17
|
Or did you mean something more like this?SELECT CONVERT(varchar, moment, 112), articleid, COUNT(*)FROM pageviewsGROUP BY CONVERT(varchar, moment, 112), articleidORDER BY CONVERT(varchar, moment, 112), COUNT(*) DESC, articleid |
 |
|
|
fizgig
Starting Member
34 Posts |
Posted - 2001-12-14 : 10:43:01
|
Nop,I would like to get the most popular daysexample output01/01/2001 23232 Hits01/02/2001 32222 Hitsetc etcquote: Or did you mean something more like this?SELECT CONVERT(varchar, moment, 112), articleid, COUNT(*)FROM pageviewsGROUP BY CONVERT(varchar, moment, 112), articleidORDER BY CONVERT(varchar, moment, 112), COUNT(*) DESC, articleid
|
 |
|
|
efelito
Constraint Violating Yak Guru
478 Posts |
Posted - 2001-12-14 : 11:21:40
|
| select convert(moment, char(10), 101), count(id)from tablenamegroup by convert(moment, char(10), 101)order by convert(moment, char(10), 101)Jeff BanschbachConsultant, MCDBA |
 |
|
|
fizgig
Starting Member
34 Posts |
Posted - 2001-12-14 : 11:33:23
|
This code throws an error unfortunately ;-(Server: Msg 164, Level 15, State 1, Line 1GROUP BY expressions must refer to column names that appear in the select list.quote: select convert(moment, char(10), 101), count(id)from tablenamegroup by convert(moment, char(10), 101)order by convert(moment, char(10), 101)Jeff BanschbachConsultant, MCDBA
|
 |
|
|
PiecesOfEight
Posting Yak Master
200 Posts |
Posted - 2001-12-14 : 11:39:55
|
Does aliasing help?select convert(moment, char(10), 101) as colname, count(id)from tablenamegroup by colnameorder by convert(moment, char(10), 101) |
 |
|
|
efelito
Constraint Violating Yak Guru
478 Posts |
Posted - 2001-12-14 : 11:44:03
|
| That's because I'm suffered a bout of syntax dyslexia.... should read like so:select convert(char(10), moment, 101), count(id)from tablenamegroup by convert(char(10), moment, 101)order by convert(char(10), moment, 101)Jeff BanschbachConsultant, MCDBA |
 |
|
|
fizgig
Starting Member
34 Posts |
Posted - 2001-12-14 : 14:41:24
|
Give the man a beer! It Worx, TNX!quote: That's because I'm suffered a bout of syntax dyslexia.... should read like so:select convert(char(10), moment, 101), count(id)from tablenamegroup by convert(char(10), moment, 101)order by convert(char(10), moment, 101)Jeff BanschbachConsultant, MCDBA
|
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2001-12-14 : 15:30:32
|
quote: Give the man a beer! It Worx, TNX!
OK, here you go Jeff, -------------------It's a SQL thing... |
 |
|
|
efelito
Constraint Violating Yak Guru
478 Posts |
Posted - 2001-12-17 : 12:06:28
|
| mmmmmm beer!Jeff BanschbachConsultant, MCDBA |
 |
|
|
|
|
|