Skip to Content
0
Dec 25, 2022 at 02:02 PM

Scripting syntax for count of prod_id

142 Views

I am facing some issues. i have following json in my memory and i want to find the count prod_id. can you please help. Thanks in Advance

[
  {
    "Prod_Id": "002",
    "cost": " 4803600.000"
  },
  {
    "Prod_Id": "004",
    "cost": " 3706404.000"
  },
  {
    "Prod_Id": "004",
    "cost": " 2784950.000"
  },
  {
    "Prod_Id": "004",
    "cost": " 4756485.000"
  },
  {
    "Prod_Id": "001",
    "cost": " 3226647.000"
  },
  {
    "Prod_Id": "002",
    "cost": " 6429540.800"
  },
  {
    "Prod_Id": "002",
    "cost": " 5521200.000"
  },
  {
    "Prod_Id": "002",
    "cost": " 5113184.050"
  },
  {
    "Prod_Id": "002",
    "cost": " 5286549.000"
  },
  {
    "Prod_Id": "002",
    "cost": " 3871875.000"
  },
  {
    "Prod_Id": "004",
    "cost": " 3093649.000"
  },
  {
    "Prod_Id": "004",
    "cost": " 5249386.000"
  },
  {
    "Prod_Id": "004",
    "cost": " 3093649.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 3108563.000"
  },
  {
    "Prod_Id": "014",
    "cost": " 1765800.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 2596000.000"
  },
  {
    "Prod_Id": "005",
    "cost": " 2484733.330"
  },
  {
    "Prod_Id": "002",
    "cost": " 7757350.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 2396000.000"
  },
  {
    "Prod_Id": "018",
    "cost": " 1143069.000"
  },
  {
    "Prod_Id": "018",
    "cost": " 2010400.000"
  },
  {
    "Prod_Id": "002",
    "cost": " 3871875.000"
  },
  {
    "Prod_Id": "005",
    "cost": " 1529123.250"
  },
  {
    "Prod_Id": "014",
    "cost": " 2500000.000"
  },
  {
    "Prod_Id": "014",
    "cost": " 2500000.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 3256538.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 2476000.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 2439810.000"
  },
  {
    "Prod_Id": "018",
    "cost": " 1042857.000"
  },
  {
    "Prod_Id": "018",
    "cost": " 1605334.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 3356894.000"
  },
  {
    "Prod_Id": "014",
    "cost": " 2689600.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 2490840.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 2657952.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 2596000.000"
  },
  {
    "Prod_Id": "006",
    "cost": " 2476000.000"
  },
  {
    "Prod_Id": "004",
    "cost": " 3707112.000"
  }
]
I want the solution as follow-->
[{
    "Prod_Id": "001",
    "Count": "1"
  },{
    "Prod_Id": "002",
    "Count": "8"
},{ "Prod_Id": "003", "Count": "2"
}, .... ]