Sure, when i run the below query.
query = from b in Logistics.Box.UHF,
where: b.admin_id == ^admin_id and b.source == ^location_id,
left_join: p in Logistics.Products.UHF, on: b.id == p.box_id,
left_join: c in Logistics.Products.Product, on: p.barcode_id == c.barcode_id,
select: %{name: c.name, image: c.image, status: b.status, barcode_id: p.barcode_id}
I get the below results
[
%{
barcode_id: "14a1e98d-a67f-464c-a92e-de75fa01abc5",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/8f49984066e04c30b091b326b33e8e72.png",
name: "NEW TV 1",
status: 3
},
%{
barcode_id: "14a1e98d-a67f-464c-a92e-de75fa01abc5",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/8f49984066e04c30b091b326b33e8e72.png",
name: "NEW TV 1",
status: 3
},
%{
barcode_id: "14a1e98d-a67f-464c-a92e-de75fa01abc5",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/8f49984066e04c30b091b326b33e8e72.png",
name: "NEW TV 1",
status: 3
},
%{
barcode_id: "a439d385-410d-4c8a-bc5b-e37caaadeaa0",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/71fb1e88daeb4dee8c3f39f6fa52c32a.jpg",
name: "NEW TV 2",
status: 3
},
%{
barcode_id: "a439d385-410d-4c8a-bc5b-e37caaadeaa0",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/71fb1e88daeb4dee8c3f39f6fa52c32a.jpg",
name: "NEW TV 2",
status: 3
},
%{
barcode_id: "a439d385-410d-4c8a-bc5b-e37caaadeaa0",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/71fb1e88daeb4dee8c3f39f6fa52c32a.jpg",
name: "NEW TV 2",
status: 1
},
%{
barcode_id: "14a1e98d-a67f-464c-a92e-de75fa01abc5",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/8f49984066e04c30b091b326b33e8e72.png",
name: "NEW TV 1",
status: 1
},
%{
barcode_id: "14a1e98d-a67f-464c-a92e-de75fa01abc5",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/8f49984066e04c30b091b326b33e8e72.png",
name: "NEW TV 1",
status: 1
},
%{
barcode_id: "14a1e98d-a67f-464c-a92e-de75fa01abc5",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/8f49984066e04c30b091b326b33e8e72.png",
name: "NEW TV 1",
status: 1
},
%{
barcode_id: "14a1e98d-a67f-464c-a92e-de75fa01abc5",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/8f49984066e04c30b091b326b33e8e72.png",
name: "NEW TV 1",
status: 1
}
]
In the above results, you can see that barcode_id is the same for several results.
If the barcode id is same then the name and image also belong to that barcode id only which will be same too.
Now i want to know the count of barcode_id plus i want to group by barcode id.
I am expecting this kind of result
[
%{
barcode_id: "14a1e98d-a67f-464c-a92e-de75fa01abc5",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/8f49984066e04c30b091b326b33e8e72.png",
name: "NEW TV 1",
count: 7 (Count of barcode ID)
},
%{
barcode_id: "a439d385-410d-4c8a-bc5b-e37caaadeaa0",
image: "https://s3.ap-south-1.amazonaws.com/hoovi234/products/71fb1e88daeb4dee8c3f39f6fa52c32a.jpg",
name: "NEW TV 2",
count: 3 (Count of barcode ID)
}
]