Can a scalar function, for example MAX, be used in WHERE...

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
Post Reply
Anjali Chopra
Website Team
Website Team
Posts: 100
Joined: Sun May 12, 2013 12:33 am

Can a scalar function, for example MAX, be used in WHERE...

Post by Anjali Chopra »

Hi,

The question is - can a scalar function, for example MAX, be used in WHERE clause for SELECT? Could anypone please guide on this.

Any help is appreciated.
Regards,
Anjali
User avatar
Anuj Dhawan
Founder
Posts: 2799
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Can a scalar function, for example MAX, be used in WHERE

Post by Anuj Dhawan »

Hi,

The answer is Yes, but there is a "but" to consder here - one should limit the usage of Scalar functions such as SUBSTR, CHAR, INT etc. in the WHERE clause. This is advised because if any scalar function is used for a column in the WHERE clause, the DB2 optimizer will not use a matching index column for the retrieval of the records from the table - and it turn, the response time of your LUW gets slow.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anjali Chopra
Website Team
Website Team
Posts: 100
Joined: Sun May 12, 2013 12:33 am

Re: Can a scalar function, for example MAX, be used in WHERE

Post by Anjali Chopra »

Thanks Anuj - this helps a lot! :)
Regards,
Anjali
maidy
Registered Member
Posts: 11
Joined: Fri Feb 21, 2014 11:57 pm

Re: Can a scalar function, for example MAX, be used in WHERE

Post by maidy »

Hello Anuj,

What do you mean by:
the response time of your LUW gets slow.
Linux, Unix and Windows?

Thanks!
Maidy
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can a scalar function, for example MAX, be used in WHERE

Post by Robert Sample »

Logical Unit of Work
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”