mysql - How do I get required result using sql -


select `id`,`amount`,'creationtime'  `table1`  amount not null group `id`;  

following query give me result:

with 2 columns,and data ordered in group.

   id       |   cash    |  creationtime    1        |   12      |   2015-10-30 07:59:11.000000    1        |   10      |   2014-10-07 08:55:27.000000    1        |   3       |   2012-10-05 06:35:48.000000    2        |   100     |   2015-10-30 07:59:11.000000    2        |   10      |   2014-10-07 08:55:27.000000    3        |   3       |   2012-10-05 06:35:48.000000 


want 1 row result, depending on creation time of row. need row amount=3 creation time oldest.

output want:

     id       |   cash    |  creationtime       1       |   3       |   2012-10-05 06:35:48.000000       2       |   10      |   2014-10-07 08:55:27.000000       3       |   3       |   2012-10-05 06:35:48.000000 

i have column, "createtime" in table. please can me how can this?

what result using:

select id,amount,creationtime table1 amount not null group id order creationtime limit 1; 

or using this:

select `id`,`amount`,'creationtime'    `table1`   amount not null  order creationtime asc limit 0,1 

result

  id       |   cash    |  creationtime   1        |   3       |   2012-10-05 06:35:48.000000 

 select `id`,`amount`,'creationtime'    `table1`   amount not null group id order creationtime asc limit 0,1 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -