hello friends : please suggest how to count column value in sql server
i.e i have one column name
products_id
and in this have two
values like 12,34
so i want to when select query execute than it show
product_id as producttotal= 2
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vinay SinghRank #604 · 4K reputationPosted Aug 1, 2016, 1:25 AM EDT
SELECT (LENGTH(product_id) - LENGTH(REPLACE(product_id,",","")) + 1) AS MyCol2Count FROM MyTable Where (LENGTH(product_id) - LENGTH(REPLACE(product_id,",","")) + 1) =2JohnRank #2,322 · 608 reputationPosted Aug 1, 2016, 12:48 AM EDT
Devendra KumarRank #3,132 · 457 reputationPosted Aug 1, 2016, 12:59 AM EDT
Vasantiandpasting
Ravi Patel
Rajeev PunhaniRank #551 · 4.4K reputationPosted Aug 1, 2016, 1:14 AM EDT
Hi Devendra,
Please find the below function.
If the above solution is helpful then,accept the answer.
Ravi PatelRank #439 · 5.7K reputationPosted Aug 1, 2016, 12:54 AM EDT