49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| --disable_query_log
 | |
| set @@session.explicit_defaults_for_timestamp=off;
 | |
| --enable_query_log
 | |
| #owner: bin.lb
 | |
| #owner group: sql1
 | |
| #tags: group_by
 | |
| #description:
 | |
| 
 | |
| ##
 | |
| ## simple test of all group functions
 | |
| ##
 | |
| #
 | |
| --disable_warnings
 | |
| drop table if exists t1,t2;
 | |
| --enable_warnings
 | |
| 
 | |
| #
 | |
| ##
 | |
| ## Test that new VARCHAR correctly works with COUNT(DISTINCT)
 | |
| ##
 | |
| #
 | |
| CREATE TABLE t1 (pk int primary key, a VARCHAR(400));
 | |
| INSERT INTO t1  VALUES (1,'A'), (2,'a'), (3,'a '), (4,'a   '),
 | |
|                           (5,'B'), (6,'b'), (7,'b '), (8,'b   ');
 | |
| SELECT COUNT(DISTINCT a) FROM t1;
 | |
| DROP TABLE t1;
 | |
| #
 | |
| ##
 | |
| ## Test for buf #9210: GROUP BY with expression if a decimal type
 | |
| ##
 | |
| #
 | |
| CREATE TABLE t1 (pk int primary key, a int, b int, c int);
 | |
| INSERT INTO t1 (pk, a, b, c) VALUES
 | |
|   (1,1,1,1), (2,1,1,2), (3,1,1,3),
 | |
|   (4,1,2,1), (5,1,2,2), (6,1,2,3),
 | |
|   (7,1,3,1), (8,1,3,2), (9,1,3,3),
 | |
|   (10,2,1,1), (11,2,1,2), (12,2,1,3),
 | |
|   (13,2,2,1), (14,2,2,2), (15,2,2,3),
 | |
|   (16,2,3,1), (17,2,3,2), (18,2,3,3),
 | |
|   (19,3,1,1), (20,3,1,2), (21,3,1,3),
 | |
|   (22,3,2,1), (23,3,2,2), (24,3,2,3),
 | |
|   (25,3,3,1), (26,3,3,2), (27,3,3,3);
 | |
| #
 | |
| SELECT b/c as v, a FROM t1 ORDER BY v, a;
 | |
| SELECT b/c as v, SUM(a) FROM t1 GROUP BY v ORDER BY v;
 | |
| SELECT SUM(a) as suma FROM t1 GROUP BY b/c ORDER BY suma;
 | |
| 
 | |
| DROP TABLE t1;
 | 
