function returns only the first qualifying value, and the remainder of the case is automatically ignored.
For example, the following SQL, you can never get the "second class" result
Case when Col_ in (' A ', ' B ') THEN ' first class ' When
Col_ in (' a ') THEN ' Second class '
else ' other ' end
Let's take a look at what we can do with the case function.
First, the known data is grouped and analyzed in a different way.
Have the following data: (in order to see more clea
analyzed in a different way.
Have the following data: (in order to see more clearly, I did not use the country code, but directly using the country name as primary Key)
Country (country) population (population)
China 600
United States 100
Canada 100
United Kingdom 200
France 300
Japan 250
Germany 200
Mexico 50
India 250
According to the population data of this country, the population of Asia and North America is counted. Should get the fo
example, the following SQL, you can never get the "second class" results
The code is as follows
Case when col_1 in (' A ', ' B ') THEN ' first class '
When Col_1 in (' a ') THEN ' Class II '
Else ' other ' end
Let's take a look at what we can do with the case function.
First, the known data is grouped and analyzed in a different way.
Have the following data: (in order to see more clearly, I did not use the country code, but directly using the country name as primary Key)
Country (countr
= function () {
emit (This.country, {count:1});
}
Reduce accepts two parameters, one is key, the first value returned by emit, and an array consisting of {count:1} documents corresponding to one or more keys.
reduce = function (key, value) {
var result = {count:0};
for (var i = 0; i
Sample table Data:
{"_id": "Country": "Japan", "Money": 724}
{"_id": "Country": "Germany", "Money": 520}
{"_id": "Country": "India", "Money": 934}
{"_id": "Country": "Our", "Money": 72
, you can never get the "second class" results
The code is as follows
Case when col_1 in (' A ', ' B ') THEN ' first class '
When Col_1 in (' a ') THEN ' Class II '
Else ' other ' end
Let's take a look at what we can do with the case function.
First, the known data is grouped and analyzed in a different way.
Have the following data: (in order to see more clearly, I did not use the country code, but directly using the country name as primary Key)
Country (country) population (population)
China 60
the case function returns only the first qualifying value, and the remainder of the case is automatically ignored.
For example, the following SQL, you can never get the "second class" results
The code is as follows
Copy Code
Case when col_1 in (' A ', ' B ') THEN ' first class 'When Col_1 in (' a ') THEN ' Class II 'Else ' other ' end
Let's take a look at what we can do with the case function.
First, the known data is grouped and analyzed in a diff
a different way to group, analysis.There is the following data: (in order to see more clearly, I did not use the country code, but directly with the country name as primary Key)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
250
the country name as primary Key)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
250
Germany
200
Mexico
50
India
250
According to the population data of this country, the p
' man ' when sex = ' 2 ' Then ' Women ' Else ' other ' ENDIn both of these ways, the same functionality can be achieved. The simple case function is relatively concise, but there are some limitations in function, such as write-judgement, compared to the search function.There is also a problem to be aware that the case function returns only the first qualifying value, and the remaining case section is automatically ignored.--for example, the following SQL, you can never get the result of a "seco
primary Key)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
250
Germany
200
Mexico
50
India
250
According to the population data of this country, the population of Asia and
to see more clearly, I did not use the country code, but directly with the country name as primary Key)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
250
Germany
200
Mexico
50
India
)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
250
Germany
200
Mexico
50
India
250
According to the population data of this country, the population of Asia and North America
, the known data is grouped in another way, analyzed. has the following data: (in order to see more clearly, I did not use the country code, but directly with the country name as primary Key)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
key)
country)
Population
China
600
USA
100
Canada
100
UK
200
France
300
Japan
250
Germany
200
Mexico
50
India
250
The population of Asia and North America is counted based on the population data of this country. The following result is returned.
electronic devices
Transfer Rate (%)
√
√
√
First pass rate (%)
√
√
√
Manufacturing cost per unit ($)
√
×
√
Material Inventory days
×
√
√
And so on...
Looking at this table, Mo Miao frowned: "You can't waste any time organizing the data. You need to focus on analyzing and coping with the factory manufacturing work ."
Alan thought for a while and thought it was time to a
key)
country)
Population
China
600
USA
100
Canada
100
UK
200
France
300
Japan
250
Germany
200
Mexico
50
India
250
The population of Asia and North America is counted based on the population data of this country. The following result is returned.
Expected results: (I got a one-to-one relationship and compared it to another table) Select * From empoylee where (address1, address2) in (select address1, address2from empoyleeadresseswhere Country = 'Canada ') the preceding method cannot be used. You can also select * from (select (zcbm |', '| fwbm), which is slow) as T from t_fwzc) TT where T not in (select (zcbm | ',' | fwbm) as C from t_zc_fc_gx) solution 1: Use exists to determine select. * From
as primary Key)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
250
Germany
200
Mexico
50
India
250
According to the population data of this country, the population of Asia
directly with the country name as primary Key)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
250
Germany
200
Mexico
50
India
250
According to the population data of this c
more clearly, I did not use the country code, but directly with the country name as primary Key)
Country (country)
Population (population)
China
600
United States
100
Canada
100
United Kingdom
200
France
300
Japan
250
Germany
200
Mexico
50
India
250
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.