MySQL Query returns undesired data

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
NeoNmaN
Forum Newbie
Posts: 21
Joined: Mon Mar 27, 2006 4:08 am
Location: Denmark
Contact:

MySQL Query returns undesired data

Post by NeoNmaN »

Now i hav this code

Code: Select all

SELECT countrynick, COUNT(DISTINCT ipadresse) AS Count, FROM_UNIXTIME(runtime, '%Y-%m-%d') AS DateNow FROM besog_log WHERE kundeid = '6' GROUP BY countrynick, FROM_UNIXTIME(runtime, '%Y-%m-%d') ORDER BY Count DESC

bot is return this dato to me

countrynick Count DateNow
DK - 21 - 2006-03-28
XX - 4 - 2006-03-28
DK - 1 - 2006-03-29
US - 1 - 2006-03-28
BG - 1 - 2006-03-28

i will hav it to look like follow

countrynick Count
DK - 22
XX - 4
US - 1
BG - 1
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Select what you want and don't select what you don't want.

Code: Select all

<?php
$sql = "SELECT countrynick, COUNT(DISTINCT ipadresse) AS Count 
        FROM besog_log 
        WHERE kundeid = '6' 
        GROUP BY countrynick
        ORDER BY Count DESC";
?>
NeoNmaN
Forum Newbie
Posts: 21
Joined: Mon Mar 27, 2006 4:08 am
Location: Denmark
Contact:

Post by NeoNmaN »

No sorry :(


countrynick Count
DK 22
XX 4
US 1
BG 1

That ist whot ist post... i whot to get a unik day and unik ip adresse counts... and all whit sam countrynick most be count to getter
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Please can you not make new topics when you alreay had a topic about this exact problem.

Ive closed the other topic
NeoNmaN
Forum Newbie
Posts: 21
Joined: Mon Mar 27, 2006 4:08 am
Location: Denmark
Contact:

Post by NeoNmaN »

How can i close the order topic ?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

NeoNmaN wrote:How can i close the order topic ?
You dont, i did it...just dont start new topics when you already have one running on the same subject.

Saves me a job ;)
NeoNmaN
Forum Newbie
Posts: 21
Joined: Mon Mar 27, 2006 4:08 am
Location: Denmark
Contact:

Post by NeoNmaN »

Ist okay :) i try to not doe it ;)

bot can you maby help my whit this sux problem? :(
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post by jrd »

could you elaborate on what you want exactly?
NeoNmaN
Forum Newbie
Posts: 21
Joined: Mon Mar 27, 2006 4:08 am
Location: Denmark
Contact:

Post by NeoNmaN »

i will only get unik ipadresse from my SQL whit timestamp = samm day thist unik ip is postet ind. and grop all contry soe if you go on my site eks. soe i wil get contry code back if you dit et to morro soe i wil get a new unik ip bot you hav a samm ip bot ist 2 days... soe now if i whot to conut today and tomorry to getter soe i whot to use a order SQL code on this

Code: Select all

SELECT countrynick, COUNT(DISTINCT ipadresse) AS Count, FROM_UNIXTIME(runtime, '%Y-%m-%d') AS DateNow FROM besog_log WHERE kundeid = '6' GROUP BY countrynick, FROM_UNIXTIME(runtime, '%Y-%m-%d') ORDER BY Count DESC
soe i can get eks.

DK = 5

or not

DK = 2 - Day 1 <- 2 unik ips
DK = 3 - Day 2 <- 3 unik ips <- 2 ips from day1 eks.
total = DK 5

bot i i remove

FROM_UNIXTIME(runtime, '%Y-%m-%d')

in my grop by soe i only get total unik ips

DK = 3 ips for day1 and day2

i hob ist help
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post by jrd »

hmmmm.... You want a total of IP hits based on distinct dates. I usually code that kind of stuff under php using a loop. If it's possible to be done in sql, i'd like to know as well. :wink:
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Usually, the number of misspellings and shortcuts in a post don't present (much) more than an annoyance, but I honestly wanted to help with this post, and cannot understand half the sentences.

Please, PLEASE, use common english, spell correctly, and restate the issue, so more people can help you. Not everyone is an english-speaking, AOL user, and understands terms like "Wot". Sorry, but there is a level where it is simply too much, and this thread has gone far beyond it.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I think that might be the best the OP can do. His location says Denmark. I am guessing that his English is not as strong as the bulk of us around here.

This sounds funny, but read his post out loud and it almost sounds understandable.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

changed topic-title from "really need help now :/" to a more meaningful one.
Post Reply