#area代码中有54个人,如何通过知道表中的计数来查找 [英] #area code with exactly 54 people in it how to find by knowing the count from the table

查看:64
本文介绍了#area代码中有54个人,如何通过知道表中的计数来查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像我们知道表中有多少计数一样,我们如何找到它。



我尝试过的事情:



 SELECT telephonenumber,LENGTH(telephonenumber)
FROM Customers;

解决方案

首先,请阅读我对这个问题的评论。



我不知道你想要达到什么,但似乎你想获得出现次数等于54的电话号码......

<前一行=SQL> SELECT C .telephonenumber
FROM 客户 AS C
GROUBY C.telephonenumber
HAVING COUNT(C.telephonenumber)= 54;





万一你想得到所有细节,请使用:



  SELECT  Final 。* 
FROM Cus tomers AS 最终
RIGHT JOIN
SELECT C.telephonenumber
FROM 客户 AS C
GROUBY C.telephonenumber
HAVING COUNT(C.telephonenumber)= 54
AS 来源 ON Final.telephonenumber = < span class =code-keyword> Source .telephonenumber;





请参考MySql文档:

MySQL :: MySQL 5.7参考手册:: 12.19.3 MySQL处理GROUP BY [ ^ ]

和这个优秀的提示: SQL连接的可视化表示 [ ^ ]


Like we know there are how many counts in table so how do we find it.

What I have tried:

SELECT telephonenumber, LENGTH(telephonenumber)
FROM Customers;

解决方案

First of all, please read my comment to the question.

I have no idea what you want to achieve, but it seems that you want to get telephone number which the number of occurrences is equal to 54...

SELECT C.telephonenumber
FROM Customers AS C
GROUBY C.telephonenumber
HAVING COUNT(C.telephonenumber)=54;



In case you want to get all details, please use this:

SELECT Final.*
FROM Customers AS Final 
  RIGHT JOIN (
    SELECT C.telephonenumber
    FROM Customers AS C
    GROUBY C.telephonenumber
    HAVING COUNT(C.telephonenumber)=54
  ) AS Source ON Final.telephonenumber = Source.telephonenumber;



Please, refer MySql documentation:
MySQL :: MySQL 5.7 Reference Manual :: 12.19.3 MySQL Handling of GROUP BY[^]
and this excelent tip: Visual Representation of SQL Joins[^]


这篇关于#area代码中有54个人,如何通过知道表中的计数来查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆