I am selecting the max value of a column from a table. If the table does not have any rows i need the result as zero. how can i achieve this

Regards

Vivek

Select ISNULL(MAX(Column),'0') from Table Where ur condition

Select ISNULL(MAX(serial_no),0) from temp_mr

error : Wrong number of arguments used with function in query expression 'ISNULL(MAX(serial_no),0)'.

Which DB ur using?
this syntax Select ISNULL(MAX(Column),'0') from Table Where ur condition is working good for me..in SQL

Which DB ur using?
this syntax Select ISNULL(MAX(Column),'0') from Table Where ur condition is working good for me..in SQL

I am using Access...

Check what parameters it accepts and pass accordingly..

I don't know if COALESCE is available under Access (but it is under SQL). It takes a variable number of arguments and returns the first value that is non NULL. If you call it like COALESCE(MAX(Column),0) it may give you what you want (again, assuming it is supported under Access).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.