Forum Moderators: coopster

Message Too Old, No Replies

Query Question

         

woldie

9:40 am on May 7, 2004 (gmt 0)

10+ Year Member



Hi,

I'm working on some stats stuff, and been trying to get a query to find the total amount clicked in the month may and also for all the other months throughout the year.

Here's my table structure...

tid
ip_address
clicked
chat_date

I think I need to get the month using MONTHNAME(chat_date) AS month, then I need to query that month in the table.

Any thoughts?

Thanks

woldie

9:57 am on May 7, 2004 (gmt 0)

10+ Year Member



okay,

I think I have solution to the problem...

SELECT distinct MONTHNAME(chat_date) AS month from tablename;

Then

select count(*) as clicked from tablename where monthname(chat_date)='May';

coopster

2:43 pm on May 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I guess it depends on how you are storing your data. Does the
clicked
column represent a single click for each
ip_address
entry? Or is it a total number of clicks for that particular entry?

woldie

2:47 pm on May 7, 2004 (gmt 0)

10+ Year Member



Hi Coopster

"Does the clicked column represent a single click for each ip_address entry? Or is it a total number of clicks for that particular entry?"

It represents a single click for each ip add, any reason why?

coopster

2:56 pm on May 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why? I just want to be sure I understand the logical representation of your data. What does the
ip_address
column represent?

fixed the style code

[edited by: coopster at 3:02 pm (utc) on May 7, 2004]

woldie

3:00 pm on May 7, 2004 (gmt 0)

10+ Year Member



What does the [fixed]ip_address[fixed] column represent?

Just want to what ip address they came from, just curiousity....

coopster

3:06 pm on May 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm not questioning why you are doing it, although if each entry represents a single click for any given
ip_address
on any given
chat_date
, the
clicked
column seems a bit redundant. You can accomplish your goal in a single SQL statement.
SELECT 
MONTHNAME(chat_date) AS month,
COUNT(*) as total
FROM clicks
GROUP BY month
;

woldie

3:19 pm on May 7, 2004 (gmt 0)

10+ Year Member



I see Coopster...

Yes you are right with your thinking, I will use your method and improve the DB structure like you say it redundant, mind you I've not really done any sort of tracking before, but I'll take you advice on board, so thanks for your help.

Cheers

:o)