Open In App

DMin and DMax Functions MS Access

1.DMin() Function :

DMin() Function in MS Access is used to determine the minimum values in a specified set of records (a domain). The DMin functions return the minimum values that satisfy the criteria. If expression identifies numeric data, the DMin functions return numeric values. If expression identifies string data, they return the string that is first alphabetically. The difference between DMin and Min is that in DMin function, values are evaluated before the data is grouped and in the case of Min function, the data is grouped before values in the field expression are evaluated.



Syntax : DMin ( expr , domain , criteria)

Parameters : 

This method accepts three-parameter as mentioned above and described below :



Returns

It returns minimum values in a specified set of records.

Table -ProcuctDetails.

Product_Id   Product_Price
101 10000
102 11000
103 5000
104 7000

Example-1 :
Finding the minimum product price

Select DMin("Product_Price", "ProcuctDetails") as Min_Price;

Output :

Min_Price
5000

Example-2 :
Finding the minimum product price for a given condition where the product id is 104.

Select DMin("Product_Price", "ProcuctDetails","Product_Id  = 104") as Min_Price;

Output :

Min_Price
7000

2.DMax() Function –

DMax() Function in MS Access is used to determine the maximum values in a specified set of records (a domain). The DMax functions return the maximum values that satisfy the criteria. If expr identifies numeric data, the DMax functions return numeric values. If expr identifies string data, they return the string that is last alphabetically. The difference between DMax and Max is that in DMax function, values are evaluated before the data is grouped and in the case of Max function, the data is grouped before values in the field expression are evaluated.

Syntax –

DMax( expr , domain , criteria)

Parameters : 

This method accepts three-parameter as mentioned above and described below :

Returns :

It returns maximum values in a specified set of records.

Table -ProcuctDetails.

Product_Id Product_Price
101 10000
102 11000
103 5000
104 7000

Example-1 :
Finding the maximum product price.

Select DMax("Product_Price", "ProcuctDetails") as Max_Price;

Output :

Max_Price
11000

Example-2 :
Finding the maximum product price for a given condition where the product id is 103.

Select DMax("Product_Price", "ProcuctDetails","Product_Id  = 103") as Max_Price;

Output :

Max_Price
5000
Article Tags :
SQL