sql - Replace count 0 with 'N/A' in mysql? -
I count my last query, last column examples, for this example I would like to change it with count 0 With 'N / A'?
This question does not seem to work
Choose m.id, m.desc, count (if iid is NULL, 'n / a' M.ID = by MID as M.ID in the form of the above query output
== ========================== m.id | C.desc | Qaunt ========================== 1234 | Shoes | 1 1235 Socks | 2 1236 Clothes | 0 =========================== Expected Result:
< Code> ============================ MDID | MADCC | Qaunt ========================== 1234 | Shoes | 1 1235 Socks | 2 1236 Clothes | N / A =========================== Would you please please suggest me that
(this has been tested) if your query is counting the results above,
above the query, And I think that I want to reciprocate, I am using a pair of IFNULL and NULLIF, which say together, "If the count is zero, translate it into tap. If this is the tap, then this column For "N / A" use.
MID, MDSC, IFNUL (NILIIF (count (ID), 0), select "N / A" MID by ID order; having pendants for mysql , You can make sure that the column is always a string by the cast ():
IFNULL (NULLIF (CAST (count (i.id) AS four), "0") , Quantity as "NA / A" in the It has the benefit of counting only once and there is no subkey.
Comments
Post a Comment