Reputation: 139
I want to count data with unique ID
buat same as pn
.This is my sample data:
id_form id_purchase pn
PUR3-20190515022552 PUR-20190515022552 02N64073
PUR2-20190515022552 PUR-20190515022552 02N64073
PUR1-20190515022552 PUR-20190515022552 02N64073
This is my code :
SELECT COUNT(*) as Total FROM pur_supp WHERE pn = '02N64073' GROUP BY id_purchase
When I run the code, that total still 3 but I want that total is 1.
Upvotes: 1
Views: 29
Reputation: 689
Try this
SELECT COUNT(DISTINCT id_purchase) as Total FROM pur_supp WHERE pn = '02N64073'
Upvotes: 3