/    Sign up×
Community /Pin to ProfileBookmark

query in query

how to make command in sql

name—-date—–traffic
aaaa—-01——-100
aaaa—-02——-103
aaaa—-03——-130
aaaa—-04——-121
aaaa—-05——-107
aaaa—-06——-109
bbbb—-01——-200
bbbb—-02——-206
bbbb—-03——-220
bbbb—-04——-321
bbbb—-05——-216
bbbb—-06——-241
cccc—-01——-65
cccc—-02——-75
cccc—-03——-87
cccc—-04——-90
cccc—-05——-98
cccc—-06——-54

i want to make same query and hope result like this

name—-date—–traffic
aaaa—-03——-121
bbbb—-04——-321
cccc—-05——-98

traffic is maximal traffic per date
date is date who traffic maximal
name is the name

can anybody help me
tx

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@checkoutmagApr 02.2008 — As simple as that,

select name,max(traffic) from sample group by name;
Copy linkTweet thisAlerts:
@checkoutmagApr 02.2008 — hi !!!

if you want to select all the three fields

select name,dat,max(traffic) from sample s

where

traffic =(select max(traffic) from sample s2 where s.name = s2.name)

group by name, dat
×

Success!

Help @irfani spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...