Queries the probability that a value appears in the database. Solution

Source: Internet
Author: User
Queries the probability that a value appears in the database. I have a two-color ball each issue of the number list, would like to ask, how to count the number 4, the probability of all the numbers in the R1-R6 (a total of 1354 records, only the first five records ). & Nbsp;, SELECTsum (sign (FIND_IN queries the probability that a value appears in the database.
I have a dual-color number table for each issue,


I would like to ask how to count the number 4, the probability that all numbers appear in the R1-R6 (a total of 1354 records, only the first five records ).


------ Solution --------------------
SELECT sum (sign (FIND_IN_SET ('4', concat (r1, ',', r2, ',', r3, ',', r4, ',', r5, ',', r6)/count (*)/6 FROM tbl_name
------ Solution --------------------
I always thought that the dual-color ball could not be duplicated. I checked the rules and it turned out to be okay.
This makes it easier.

Select sum (if (r1 =, 0) + if (r2 =, 0) + if (r3 =, 0) + if (r4 =, 0) + if (r5 = 4,1, 0) + if (r6 = 4,1, 0)/count (*)/6 FROM tbl_name

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.