May-05-2019, 10:22 AM
My pyodbc returns cursor result as below
Salesamount should split based on the year to sub list.
>>> type(result)
<class 'list'>
>>> result [(Decimal('28000.0000'), 2010, 272), (Decimal('308000.0000'), 2011, 272), (Decimal('582000.0000'), 2012, 272), (Decimal('387000.0000'), 2013, 272), (Decimal('367000.0000'), 2010, 281), (Decimal('3037000.0000'), 2011, 281), (Decimal('4822000.0000'), 2012, 281), (Decimal('2936000.0000'), 2013, 281), (Decimal('637000.0000'), 2010, 282), (Decimal('3440000.0000'), 2011, 282), (Decimal('4415000.0000'), 2012, 282), (Decimal('3294000.0000'), 2013, 282), (Decimal('478000.0000'), 2010, 296), (Decimal('1209000.0000'), 2011, 296), (Decimal('478000.0000'), 2012, 296), (Decimal('1209000.0000'), 2013, 296)] >>>how to get data in list as below
Salesamount should split based on the year to sub list.
Salesamount = [[28000.00,308000.00,582000.00,387000.00],[367000.00,3037000.00,4822000.00,2936000.00],[637000.00,3440000.00,4415000.00,3294000.00],[478000.00,1209000.00,478000.00,1209000.00]] CalendarYear = [2010,2011,2012,2013] Employee = [272,281,282,296]Also how to remove decimal as it is displaying as decimal in the list
>>> type(result)
<class 'list'>