Mysql queries the content of rows that are not repeated, the number of records that are not repeated count, distinct

Source: Internet
Author: User


Mysql queries non-duplicated row content and the number of non-Repeated Records count. distinct has such a table that records id, p_id, p_name, p_content, p_time 1 343 aaa aaaaaa 2012-09-01 2 344 bbb bbbbbb 2012-09-02 3 321 ccc cccccccc 2012-09-03 www.2cto.com 4 343 aaa aaaaaa 2012-09-04 want to query the content of non-repeated rows, and output p_sum (number of product p_id repetitions) select *, count (*) as p_sum from p_table_name group by p_name; query the total number of rows that do not repeat (easy to write) select count (distinct p_id) as num from p_table_name;
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.