Counting pages - Mailing list pgsql-general

From Justin Long
Subject Counting pages
Date
Msg-id 001801bee440$f9878280$95421a9f@nsmjustinlong.cbn.org
Whole thread Raw
In response to Re: [GENERAL] Oracle vs. Postgres  ("Jonathan davis" <haj@idianet.net>)
List pgsql-general
I have a question that I cannot seem to solve; I don't know if I should post
it here or somewhere else, but here goes.

I have a logbook database which tracks which pages are being accessed on our
site. I would like to know what the pages with the highest "hits" are. Each
time a page is hit, that page's ID # is stored in the database.

I've tried the following

    SELECT l1.location, count(l2.location) from logbook l1, logbook l2
        where l1.location = l2.location

That was just a guess but of course it didn't work. I've run into this
problem with some related issues; for example, I'd like to be able to give a
particular user a hot link to his/her most referenced page, deducing it in a
simlar way

    SELECT u.userid, count(l.location) from logbook l, member u
        where l.userid=u.userid

But this doesn't work either. I get an error message: 'Illegal use of
aggregates or non-group column in target list.' I've looked over the
documentation but either I'm going blind or stupid because I just don't get
it. Anyone else solved this one?

Thanks,
Justin Long


Never retreat. Never surrender. Never cut a deal with a dragon.
_______________________________________________________________
Justin Long                   CIO / Site Editor
616 Station Square Ct         Network for Strategic Missions
Chesapeake, VA 23320          977 Centerville Trnpk CSB 317
JustinLong@xc.org             Va Beach, VA 23463
Check out our site at:        http://www.strategicnetwork.org


pgsql-general by date:

Previous
From: "Justin Long"
Date:
Subject: RE: [GENERAL] Oracle vs. Postgres
Next
From: Charles Tassell
Date:
Subject: Re: [GENERAL] Problem with compiled C