The SELECT statement containing group by in MySQL displays the result of 0 in COUNT ().
Mysql> select * from t1; + ------- + ------ + | level | name | + ------- + ------ + | 1 | a | 1 | B | 1 | c | 2 | a | 2 | B | | 4 | a | 5 | B | + ------- + ------ + 7 rows in set (0.00 sec) mysql> select * from t2; + ------ + | id | + ------ + | 1 | 2 | 3 | 4 | 5 | + ------ + 5 rows in set (0.02 sec) mysql> select t2.id
A group of monkeys in a circle, according to 1,2,...,n sequentially numbered. Then, starting from the 1th, Count to M., Kick It Out of the loop, start counting from behind it, Count to M., and Kick It out ... and so on, until the last monkey is left, the monkey is called the King. Requires programming to simulate this process, enter m, N, output the last king's n
ON SC.[C#]=C.[C#] GROUP BY [S#] HAVING COUNT(*)=COUNT(DISTINCT [S#]))
5. query the number of students who have selected the course
-- Implementation code:
SELECT students = COUNT (DISTINCT [S #]) FROM SC
6. query the student ID and organization of more than 5 Elective Courses
-- Implementation code:
SELECT SN,
// use hibernate to implement group by and sum and count session sess = this. getsession (false); List list = NULL; If (sess! = NULL) { Criteria CRI = sess. createcriteria (getmodelclass (); CRI. add (expression. alleq (props); // always count id projectionlist projlist = projections. projectionlist (); projlist. add (projections. sum (SUM); projlist. add
Reference Problem description:
There are three tables:
Student Information table S (sno, sname)
Course information table C (cno, cname, cteacher)
Student-course relationship table SC (sno, cno, scroce)
Question 1: find out the names of all students who have not taken the course taught by Mr. Li Ming.
Question 2: The name of two or more failed students is displayed.
Question 3: find out the names of students who have selected both course "1" and course "2 ".
Main test:
As shown in the following table: Table-----------------------------------Filed0 filed1-----------------------------------A 1A 2A 2B 2B 3B 3------------------------------------Run: Select filed0, count (*) from table where filed1> 2 group by filed0Expected result:------------------------------------B 2------------------------------------Run: (select filed0, count
The SQL statement counts the number of people by age group. bitsCN.com
Number of SQL statements grouped by age group
Java code
Create table # t (Uname varchar (10), age int)
Insert # t
Select 'ah', 19 union all
Select 'info', 23 union all
Select 'baby', 31 union all
Select 'random Wo', 21 union all
Select 'mimeters ', 6
Select nnd as 'age group',
intF1; 7 Longfirst=-1, num=0;//First: The subscript that appears for the initial time. Num: Total number of occurrences8 Charch; 9 inti; Ten intindex=-1;//indicates the subscript for the current scanned article Onescanf"%s", S1); AGetChar ();//absorbing carriage return characters - for(i=0; s1[i]!=' /'; i++) - { the if(s1[i]>='A's1[i]'Z')//if uppercase, it becomes a lowercase letter -s1[i]=s1[i]+ +; - } -f1=0;//You have not started to enter
Label:1. Multi-line functionwhichMax (field)-----------Maximum valueMin (field)----------Minimum valuesum (field)-----------sumAVG (field)-------------averagingCont (field or *)----------count the field data, * Calculate the number of rows of dataSeveral are multi-line functions, if there is such a function in the statement without writing groupby a fieldThe function avg () calculates all the rows of data and gets a single data, which is a multiline f
. If a given word is found in the article, two integers are output, which are separated by a space,The number of times a word appears in an article and the position where it appears for the first time.Position of the parent in the article, starting from 0). If a word does not appear in the article, an integer-1 is output directly.
Input and Output Example 1
Input:
ToTo be or not to be is a question
Output:
2 0
[Input and Output Example 1]The output result indicates that the given word
1064 Insect Food Count 2004 years Noip National League Improvement GroupTime limit:2 S Space limit: 128000 KBTitle Level:Diamond Diamonds Title Description DescriptionThe so-called insect food calculation, is a part of the original formula has been chewed off by the worm, we need to determine the number of the remaining numbers to be chewed off the letter. Let's look at a simple example:43#9865#045+ 8468#663344445506978The # number represents the numb
Problems with large Array count group subscript
The test code is as follows:
$int = 135893597710;Print_r ($int);Print_r (Array ($int =>1));
The output is 135893597710Array on Windows ([ -1545355762] = 1)
Get the right results when you go to Linux 135893597710Array ([135893597710] + 1)
How can I get the correct results on Windows
Share to:
1));输出结果在windows上是1358935..." data-pics="">1));输出结果在windows上
; i i) the { -dp[i][1] = val[0][i];Wuyi } the for(inti =0; i i) - { Wu for(intj =0; J j) - { About for(intK =2; K k) $ { -Dp[i][k] = max (Dp[i][k], dp[j][k-1] + val[j+1][i]); - intBBB =1; - } A } + } thecout 1][K] Endl; - $ the the /*cout the for (int i = 0; i the { - For (int j = 0; j in { the cout the } About cout the } the the cout + for (int i = 0; i -
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.