I want to count the number of fields a in a table. Because field a has repeated records, I want to exclude repeated records. The SQL statement is:
Select count (distinct)
Link: http://www.w3school.com.cn/ SQL/SQL
Test table: StudentSelect from Studnet;Select Count (distinct from student;Select Count (distinct from student;This is wrong, can be adapted to achieveSelect Count from (Selectdistinct from student) St; Blocked, I'm going the other way!SQL Server
Hours server queries the number of coaches, use the Select COUNT (Distinct (U_strno)) times to exceed memory errors. After reference "Mysqld-nt:out of memory Solution"
Oracle left join... ON... AND... and left join... ON... WHERE... difference about left join... on... and... and left join... on... the difference between where is that many online statements are about left join... on... and ..., and conditions only
Players in a certain period of time to register to start the game, after a period of time, still continue to play is considered to be retained; This part of the user accounted for the new user ratio that is the retention rate, according to every 1
SELECT * from Rpt_history_money where Customer_price_per_day =0 and Real_pay_money SELECT * from Rpt_history_money_detail where Customer_price_per_day SELECT * from Rpt_history_money where date (serviced_days) > Date (beable_service_days);SELECT
Mysql statistics retention rate bitsCN.com
Mysql statistics retention rate
SQL code
Begin
Declare I int;
Declare numareaId int (10 );
Declare currentareaId int (10 );
Select count (areaId), MIN (areaId) INTO @ a, @ B FROM option_area_info;
SET
The following 4 SQL, which is obviously a 2-class SQL statement. May 19, 2017Question: Walked two times the full table.Select COUNT (*) active merchant number from (select Merchant_code,count (DISTINCT concat (Merchant_code,date (create_date)))
Mysql index and optimization, mysql INDEX OPTIMIZATION
Today, I saw some articles about mysql indexes written by others, but I had some small gains. I just started my essay record and briefly picked some important points.
Repost:
The content of this chapter is based entirely on the theoretical basis above. In fact, once you understand the mechanisms behind the index, selecting a high-performance policy becomes pure reasoning, and you can understand the logic behind these
The ideal index:
Tables with very frequent table queries are indexed relative to write operations
High field sensitivity
The length is small (suitable length, not the smaller the better)
Try to cover characters commonly used
The usage policy and optimization (high-performance index policy) bitsCN.com in this chapter are based on the above theoretical basis. In fact, once you understand the mechanism behind the index, therefore, selecting a high-performance policy
Standalone index:A stand-alone index refers to an indexed column that cannot be part of an expression, or a function's argument Example 1:SELECTactor_id fromActorWHEREactor_id+1=5--This writing, even if the index on the actor_id, it does not
Select--Total number of registered persons(Select COUNT (*) from [Yyd_users_reginfo]) as TotalCount,--PC Terminal number of registered(Select COUNT (*) from [yyd_users_reginfo] where regplatform = ' pc ') as Pctotalcount,--Number of registered
Analysis of MySQL's tips for optimizing distinct, mysqldistinct
There is a need: select count (distinct nick) from user_access_xx_xx;
This SQL statement is used to calculate the uv of user access. Because the data volume in a single table is more
I now have a table, no primary key, only one union unique (Date,user_id,count_name,)Table Record Example: date:20160808 user_id:556 count_name:a1
Date represents the day, user_id represents the user's ID, and count_name represents a statistic
Count (distinct key) case
explain select count(distinct session_id) from trackinfo where ds=‘ 2013-07-21‘ ;STAGE DEPENDENCIES: Stage-1 is a root stage Stage-0 is a root stageSTAGE PLANS: Stage: Stage-1 Map Reduce Alias -> Map Operator
I now have a table with no primary key. there is only one union unique (date, user_id, count_name,) Table record example: date: 20160808user_id: 556count_name: a1date indicates the date, user_id indicates the user id, and count_name indicates a
Mysql-High-Performance Index policy, mysql-High-Performance IndexIndependent index:
An independent index means that an index Column cannot be part of an expression or a function parameter.
Example 1:SELECT actor_id FROM actor WHERE actor_id + 1 = 5
web| Page | Optimization example of Web page-turning optimization
Author: Wanghai
Environment:
Linux version 2.4.20-8custom (ROOT@WEB2) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #3 SMP Thu June 5 22:03:36 CS T 2003
mem:2113466368
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.