Domanda

I have an MySQL-statement like

SELECT COUNT(*) FROM xy

I get a number like 1443223. But I want thousands-separators, e.g. 1.443.223. What I found here (use of FORMAT) produced only an error. I tried e.g.

SELECT FORMAT(COUNT( * ), 2, 'de_DE')

Well ... Perhaps anybody out there is knowing an answer? Thanks!

EDIT: The error I am getting is

Error Number: 1582

Incorrect parameter count in the call to native function 'FORMAT'

SELECT FORMAT(COUNT( * ), 2, 'de_DE') AS anzahl FROM xy a WHERE a.typ = 'IHK' AND a.datum >=2014

È stato utile?

Soluzione

I tried these two queries and they are perfectly working fine:

SELECT FORMAT((SELECT COUNT(*) FROM xy), 2, 'de_DE');
SELECT FORMAT((SELECT count(*) FROM xy a WHERE a.typ = 'IHK' AND a.datum >=2014), 2, 'de_DE') AS anzahl;

the second query is from the error that you are getting, try this once, it should work. I tested it.

What is the version of MySQL that you are using? try this also:

SELECT FORMAT((SELECT COUNT(*) FROM xy), 2);
SELECT FORMAT((SELECT count(*) FROM xy a WHERE a.typ = 'IHK' AND a.datum >=2014), 2) AS anzahl;

Altri suggerimenti

You can Try this:

SELECT FORMAT((SELECT COUNT( * ) FROM XY), 2, 'de_DE')

I just tried it like so:

SELECT FORMAT(COUNT(*), 2, 'de_DE') FROM your_table

and it works. Maybe you were missing the FROM... clause?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top