mysql - SQL: Changing structure of sql table with a million rows -
i have table(lets call mytable) below structure. table records close 1 million rows everyday.
id date timestamp licenseid storeid deviceid value 1 2015-06-12 17:36:15 lic0001 1 0add -52 2 2015-06-12 17:36:15 lic0002 1 0add -54 3 2015-06-12 17:36:15 lic0003 1 0add -53 4 2015-06-12 17:36:21 lic0001 1 0add -54 5 2015-06-12 17:36:21 lic0002 1 0add -59 6 2015-06-12 17:36:21 lic0003 1 0add -62 7 2015-06-12 17:36:21 lic0004 1 0add -55 8 2015-06-12 17:36:15 lic0001 1 0bdd -53 9 2015-06-12 17:36:15 lic0002 1 0bdd -52 10 2015-06-12 17:36:15 lic0003 1 0bdd -52 11 2015-06-12 17:36:15 lic0004 1 0bdd -50 12 2015-06-12 17:36:33 lic0002 1 0bdd -54 13 2015-06-12 17:36:33 lic0003 1 0bdd -54 14 2015-06-12 17:36:33 lic0004 1 0bdd -55 15 2015-06-12 17:36:33 lic0005 1 0bdd -40
i need use same data above , rearrange in new table end of day below. sql query should use below output , store in new table called 'newtable' considering table size. number of licenseids variable.
id date timestamp deviceid storeid lic001 lic002 lic003 lic004 lic005.... 1 2015-06-12 17:36:15 0add 1 -52 -54 -53 2 2015-06-12 17:36:21 0add 1 -54 -59 -62 -55 3 2015-06-12 17:36:15 0bdd 1 -53 -52 -52 -50 4 2015-06-12 17:36:33 0bdd 1 -54 -54 -55 -40
i need to perform calculations each deviceid per timestamp per storeid , arrive @ conversion each value , unique value each deviceid per store per timestamp based on known equation , using individual license values.
Comments
Post a Comment