Skip to main content
1-Visitor
May 2, 2018 10:39 AM UTC
Question

How to add Max function QuerySpec

Hello,

 

I trying to create a QuerySpec to retrieve highest branchIditerationInfo (using MAX function) value to get the latest most object

 

Thanks

 

Ankit

2 replies

12-Amethyst
May 8, 2018 3:12 PM UTC

You do something similar to the following:

 

QuerySpec subSelect = new QuerySpec();
subSelect.setAdvancedQueryEnabled(true);

ClassAttribute versionSortId = new ClassAttribute(WTPart.class, "versionInfo.identifier.versionSortId");
SQLFunction maxFunction = SQLFunction.newSQLFunction(SQLFunction.MAXIMUM, versionSortId);

subSelect.appendSelect(maxFunction, new int[]{wtPartIndex}, false);

 

This should get you headed in the right direction.

Translate
ShirishMorkhade
16-Pearl
May 30, 2018 6:31 PM UTC

Hello Ankit,

Windchill help center has nice elaboration about SQLFunction here at

http://support.ptc.com/cs/help/windchill_hc/wc102_hc/index.jspx?id=WCCG_Serv_AdvQuery_SearchCondition&action=show

 

This contains an example of SQLFunction.MINIMUM but it will more or less identical for SQLFunction.MAXIMUM.

 

I hope this will help you in what you want to achieve.

 

Regards,

Shirish

Translate