Wednesday, July 6, 2011

Format query result by count() with comma using Format()

I played around with MySQL count() statement. I found it annoying that the count()
will simply return whole numbers. Example: the total record of a table is 32,272.
In MySQL SQL, this will simply return 32272. Below are two sql scripts. The first
one returns whole number,while the second query returns comma separated number.

ENJOY!!!!
1:  select count(*) as num_records_notformatted from mytable where name like '%j%';  
2:  Solution:  
3:  select format(count(id),0) as num_records_formatted from mytable   
4:  where name like '%j%';  

0 comments:

Post a Comment