I'm afraid I don't understand your results. When I run your experiment, "2" is the name and label of the second column of the query "SELECT country,count(*) FROM customer GROUP BY country ORDER BY country". Does the following give you what you want:

  SELECT country,count(*) AS "count(*)" FROM customer GROUP BY country ORDER BY country


On 7/4/22 6:01 AM, John English wrote:
I have a query SELECT COUNT(*) AS X FROM ...

If I use ResultMetaData.getColumnLabel(), I get "X".
If I use ResultMetaData.getColumnName(), I also get "X".

Here is the output from a test program:

Query: SELECT country,count(*) FROM customer GROUP BY country ORDER BY country
Name = COUNTRY
Label = COUNTRY
Name = COUNT(*)
Label = COUNT(*)
columns = COUNT(*), COUNTRY

Query: select country, count(*) as customers from customer group by country order by country asc
Name = COUNTRY
Label = COUNTRY
Name = CUSTOMERS
Label = CUSTOMERS
columns = COUNTRY, CUSTOMERS

I was hoping/expecting that getColumnName() would return "COUNT(*)" in the second case.

Is there any way to get COUNT(*) short of parsing the query myself?

Thanks,


Reply via email to