mysql - how to set column type with create-select statement -


i trying create table select statement , doesn't require me set column types. need column percent float getting 0 , 1s. how set column float or decimal?

create table c as(     select a.pid, b.date,     ((select a.count(cost) cost > '10')/(select a.count(cost))) percent     a join b b     on a.pid = b.pid     group 1,2,3); 

my output below need third col float:

pid date percent 1   2015-01-01  1 2   2015-04-03  0 

how about:

create table c as(     select a.pid, b.date,     ((select a.count(cost)*1.000 cost > '10')/(select a.count(cost))) percent a join b b on a.pid = b.pid group 1,2,3); 

edit: nevermind above

the following tested , appears happy float.

create table i1 (     h varchar(10),     g varchar(10) ); insert i1 (h,g) values ('a','b'),('a','b');  -- drop table c;  create table c (percent float not null)  select h,count(*) percent i1  describe c; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -