📄 type_newdecimal.result
字号:
drop table if exists t1;select 1.1 IN (1.0, 1.2);1.1 IN (1.0, 1.2)0select 1.1 IN (1.0, 1.2, 1.1, 1.4, 0.5);1.1 IN (1.0, 1.2, 1.1, 1.4, 0.5)1select 1.1 IN (1.0, 1.2, NULL, 1.4, 0.5);1.1 IN (1.0, 1.2, NULL, 1.4, 0.5)NULLselect 0.5 IN (1.0, 1.2, NULL, 1.4, 0.5);0.5 IN (1.0, 1.2, NULL, 1.4, 0.5)1select 1 IN (1.11, 1.2, 1.1, 1.4, 1, 0.5);1 IN (1.11, 1.2, 1.1, 1.4, 1, 0.5)1select 1 IN (1.11, 1.2, 1.1, 1.4, NULL, 0.5);1 IN (1.11, 1.2, 1.1, 1.4, NULL, 0.5)NULLselect case 1.0 when 0.1 then "a" when 1.0 then "b" else "c" END;case 1.0 when 0.1 then "a" when 1.0 then "b" else "c" ENDbselect case 0.1 when 0.1 then "a" when 1.0 then "b" else "c" END;case 0.1 when 0.1 then "a" when 1.0 then "b" else "c" ENDaselect case 1 when 0.1 then "a" when 1.0 then "b" else "c" END;case 1 when 0.1 then "a" when 1.0 then "b" else "c" ENDbselect case 1.0 when 0.1 then "a" when 1 then "b" else "c" END;case 1.0 when 0.1 then "a" when 1 then "b" else "c" ENDbselect case 1.001 when 0.1 then "a" when 1 then "b" else "c" END;case 1.001 when 0.1 then "a" when 1 then "b" else "c" ENDccreate table t1 (a decimal(6,3));insert into t1 values (1.0), (NULL), (0.1);select * from t1;a1.000NULL0.100select 0.1 in (1.0, 1.2, 1.1, a, 1.4, 0.5) from t1;0.1 in (1.0, 1.2, 1.1, a, 1.4, 0.5)0NULL1drop table t1;create table t1 select if(1, 1.1, 1.2), if(0, 1.1, 1.2), if(0.1, 1.1, 1.2), if(0, 1, 1.1), if(0, NULL, 1.2), if(1, 0.22e1, 1.1), if(1E0, 1.1, 1.2);select * from t1;if(1, 1.1, 1.2) if(0, 1.1, 1.2) if(0.1, 1.1, 1.2) if(0, 1, 1.1) if(0, NULL, 1.2) if(1, 0.22e1, 1.1) if(1E0, 1.1, 1.2)1.1 1.2 1.1 1.1 1.2 2.2 1.1show create table t1;Table Create Tablet1 CREATE TABLE `t1` ( `if(1, 1.1, 1.2)` decimal(2,1) NOT NULL default '0.0', `if(0, 1.1, 1.2)` decimal(2,1) NOT NULL default '0.0', `if(0.1, 1.1, 1.2)` decimal(2,1) NOT NULL default '0.0', `if(0, 1, 1.1)` decimal(2,1) NOT NULL default '0.0', `if(0, NULL, 1.2)` decimal(2,1) default NULL, `if(1, 0.22e1, 1.1)` double NOT NULL default '0', `if(1E0, 1.1, 1.2)` decimal(2,1) NOT NULL default '0.0') ENGINE=MyISAM DEFAULT CHARSET=latin1drop table t1;create table t1 select nullif(1.1, 1.1), nullif(1.1, 1.2), nullif(1.1, 0.11e1), nullif(1.0, 1), nullif(1, 1.0), nullif(1, 1.1);select * from t1;nullif(1.1, 1.1) nullif(1.1, 1.2) nullif(1.1, 0.11e1) nullif(1.0, 1) nullif(1, 1.0) nullif(1, 1.1)NULL 1.1 NULL NULL NULL 1show create table t1;Table Create Tablet1 CREATE TABLE `t1` ( `nullif(1.1, 1.1)` decimal(2,1) unsigned default NULL, `nullif(1.1, 1.2)` decimal(2,1) unsigned default NULL, `nullif(1.1, 0.11e1)` decimal(2,1) unsigned default NULL, `nullif(1.0, 1)` decimal(2,1) unsigned default NULL, `nullif(1, 1.0)` int(1) default NULL, `nullif(1, 1.1)` int(1) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1drop table t1;create table t1 (a decimal(4,2));insert into t1 value (10000), (1.1e10), ("11111"), (100000.1);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1Warning 1264 Out of range value adjusted for column 'a' at row 2Warning 1264 Out of range value adjusted for column 'a' at row 3Warning 1264 Out of range value adjusted for column 'a' at row 4insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1Warning 1264 Out of range value adjusted for column 'a' at row 2Warning 1264 Out of range value adjusted for column 'a' at row 3Warning 1264 Out of range value adjusted for column 'a' at row 4select a from t1;a99.9999.9999.9999.99-99.99-99.99-99.99-99.99drop table t1;create table t1 (a decimal(4,2) unsigned);insert into t1 value (10000), (1.1e10), ("11111"), (100000.1);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1Warning 1264 Out of range value adjusted for column 'a' at row 2Warning 1264 Out of range value adjusted for column 'a' at row 3Warning 1264 Out of range value adjusted for column 'a' at row 4insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1Warning 1264 Out of range value adjusted for column 'a' at row 2Warning 1264 Out of range value adjusted for column 'a' at row 3Warning 1264 Out of range value adjusted for column 'a' at row 4select a from t1;a99.9999.9999.9999.990.000.000.000.00drop table t1;create table t1 (a bigint);insert into t1 values (18446744073709551615.0);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1insert into t1 values (9223372036854775808.0);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1insert into t1 values (-18446744073709551615.0);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1select * from t1;a92233720368547758079223372036854775807-9223372036854775808drop table t1;create table t1 (a bigint unsigned);insert into t1 values (18446744073709551615.0);insert into t1 values (9223372036854775808.0);insert into t1 values (9999999999999999999999999.000);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1insert into t1 values (-1.0);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1select * from t1;a184467440737095516159223372036854775808184467440737095516150drop table t1;create table t1 (a tinyint);insert into t1 values (18446744073709551615.0);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1Warning 1264 Out of range value adjusted for column 'a' at row 1insert into t1 values (9223372036854775808.0);Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 1Warning 1264 Out of range value adjusted for column 'a' at row 1select * from t1;a127127drop table t1;create table t1 select round(15.4,-1), truncate(-5678.123451,-3), abs(-1.1), -(-1.1);show create table t1;Table Create Tablet1 CREATE TABLE `t1` ( `round(15.4,-1)` decimal(3,0) unsigned NOT NULL default '0', `truncate(-5678.123451,-3)` decimal(4,0) NOT NULL default '0', `abs(-1.1)` decimal(2,1) NOT NULL default '0.0', `-(-1.1)` decimal(2,1) NOT NULL default '0.0') ENGINE=MyISAM DEFAULT CHARSET=latin1drop table t1;set session sql_mode='traditional';select 1e10/0e0;1e10/0e0NULLWarnings:Error 1365 Division by 0create table wl1612 (col1 int, col2 decimal(38,10), col3 numeric(38,10));insert into wl1612 values(1,12345678901234567890.1234567890,12345678901234567890.1234567890);select * from wl1612;col1 col2 col31 12345678901234567890.1234567890 12345678901234567890.1234567890insert into wl1612 values(2,01234567890123456789.0123456789,01234567890123456789.0123456789);select * from wl1612 where col1=2;col1 col2 col32 1234567890123456789.0123456789 1234567890123456789.0123456789insert into wl1612 values(3,1234567890123456789012345678.0123456789,1234567890123456789012345678.0123456789);select * from wl1612 where col1=3;col1 col2 col33 1234567890123456789012345678.0123456789 1234567890123456789012345678.0123456789select col1/0 from wl1612;col1/0NULLNULLNULLWarnings:Error 1365 Division by 0Error 1365 Division by 0Error 1365 Division by 0select col2/0 from wl1612;col2/0NULLNULLNULLWarnings:Error 1365 Division by 0Error 1365 Division by 0Error 1365 Division by 0select col3/0 from wl1612;col3/0NULLNULLNULLWarnings:Error 1365 Division by 0Error 1365 Division by 0Error 1365 Division by 0insert into wl1612 values(5,5000.0005,5000.0005);insert into wl1612 values(6,5000.0005,5000.0005);select sum(col2),sum(col3) from wl1612;sum(col2) sum(col3)1234567903703703580370380357.1491481468 1234567903703703580370380357.1491481468insert into wl1612 values(7,500000.000005,500000.000005);insert into wl1612 values(8,500000.000005,500000.000005);select sum(col2),sum(col3) from wl1612 where col1>4;sum(col2) sum(col3)1010000.0010100000 1010000.0010100000insert into wl1612 (col1, col2) values(9,1.01234567891);Warnings:Note 1265 Data truncated for column 'col2' at row 1insert into wl1612 (col1, col2) values(10,1.01234567894);Warnings:Note 1265 Data truncated for column 'col2' at row 1insert into wl1612 (col1, col2) values(11,1.01234567895);Warnings:Note 1265 Data truncated for column 'col2' at row 1insert into wl1612 (col1, col2) values(12,1.01234567896);Warnings:Note 1265 Data truncated for column 'col2' at row 1select col1,col2 from wl1612 where col1>8;col1 col29 1.012345678910 1.012345678911 1.012345679012 1.0123456790insert into wl1612 (col1, col3) values(13,1.01234567891);Warnings:Note 1265 Data truncated for column 'col3' at row 1insert into wl1612 (col1, col3) values(14,1.01234567894);Warnings:Note 1265 Data truncated for column 'col3' at row 1insert into wl1612 (col1, col3) values(15,1.01234567895);Warnings:Note 1265 Data truncated for column 'col3' at row 1insert into wl1612 (col1, col3) values(16,1.01234567896);Warnings:Note 1265 Data truncated for column 'col3' at row 1select col1,col3 from wl1612 where col1>12;col1 col313 1.012345678914 1.012345678915 1.012345679016 1.0123456790select col1 from wl1612 where col1>4 and col2=1.01234567891;col1select col1 from wl1612 where col1>4 and col2=1.0123456789;col1910select col1 from wl1612 where col1>4 and col2<>1.0123456789;col156781112select col1 from wl1612 where col1>4 and col2<1.0123456789;col1select col1 from wl1612 where col1>4 and col2<=1.0123456789;col1910select col1 from wl1612 where col1>4 and col2>1.0123456789;col156781112select col1 from wl1612 where col1>4 and col2>=1.0123456789;col156789101112select col1 from wl1612 where col1>4 and col2=1.012345679;col11112select col1 from wl1612 where col1>4 and col2<>1.012345679;col15678910select col1 from wl1612 where col1>4 and col3=1.01234567891;col1select col1 from wl1612 where col1>4 and col3=1.0123456789;col11314select col1 from wl1612 where col1>4 and col3<>1.0123456789;col156781516select col1 from wl1612 where col1>4 and col3<1.0123456789;col1select col1 from wl1612 where col1>4 and col3<=1.0123456789;col11314select col1 from wl1612 where col1>4 and col3>1.0123456789;col156781516select col1 from wl1612 where col1>4 and col3>=1.0123456789;col1567813141516select col1 from wl1612 where col1>4 and col3=1.012345679;col11516select col1 from wl1612 where col1>4 and col3<>1.012345679;col156781314drop table wl1612;select 1/3;1/30.3333select 0.8=0.7+0.1;0.8=0.7+0.11select 0.7+0.1;0.7+0.10.8create table wl1612_1 (col1 int);insert into wl1612_1 values(10);select * from wl1612_1 where 0.8=0.7+0.1;col110select 0.07+0.07 from wl1612_1;0.07+0.070.14select 0.07-0.07 from wl1612_1;0.07-0.070.00select 0.07*0.07 from wl1612_1;0.07*0.070.0049select 0.07/0.07 from wl1612_1;0.07/0.071.000000drop table wl1612_1;create table wl1612_2 (col1 decimal(10,2), col2 numeric(10,2));insert into wl1612_2 values(1,1);insert into wl1612_2 values(+1,+1);insert into wl1612_2 values(+01,+01);insert into wl1612_2 values(+001,+001);select col1,count(*) from wl1612_2 group by col1;col1 count(*)1.00 4select col2,count(*) from wl1612_2 group by col2;col2 count(*)1.00 4drop table wl1612_2;create table wl1612_3 (col1 decimal(10,2), col2 numeric(10,2));insert into wl1612_3 values('1','1');insert into wl1612_3 values('+1','+1');insert into wl1612_3 values('+01','+01');insert into wl1612_3 values('+001','+001');select col1,count(*) from wl1612_3 group by col1;col1 count(*)1.00 4select col2,count(*) from wl1612_3 group by col2;col2 count(*)1.00 4drop table wl1612_3;select mod(234,10) ;mod(234,10)4select mod(234.567,10.555);mod(234.567,10.555)2.357select mod(-234.567,10.555);mod(-234.567,10.555)-2.357select mod(234.567,-10.555);mod(234.567,-10.555)2.357select round(15.1);round(15.1)15select round(15.4);round(15.4)15select round(15.5);round(15.5)16select round(15.6);round(15.6)16select round(15.9);round(15.9)16select round(-15.1);round(-15.1)-15select round(-15.4);round(-15.4)-15select round(-15.5);round(-15.5)-16select round(-15.6);round(-15.6)-16select round(-15.9);round(-15.9)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -