0

My table in Mysql is like this:

 IP       ID     area
 aaa      A        I
 aaa      A        I
 aaa      B        I  
 aaa      C        II
 bbb      A        I
 bbb      B        III
 ccc      B        I

Now I want to calculate for each area value, how many different (IP, ID) pairs are there?

How can I use both IP and ID as a whole dataset to do this?

I don't think the following query is correct:

SELECT area, count (distinct IP, ID) from video GROUP BY area ORDER BY COUNT (distinct ip, ID)

So does anyone know how to do it?

0

2 Answers 2

1
SELECT count(*), CONCAT_WS(' ',IP,ID) as yourTitle FROM video GROUP BY yourTitle

should do

Sign up to request clarification or add additional context in comments.

Comments

0
SELECT area, count(*) as distinctCount FROM 
  (SELECT DISTINCT IP, ID, area FROM video) distinctVideos 
GROUP BY area
ORDER BY count(*)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.