* @param employeeId
*/
private static void querySample(Connection conn, int employeeId)
{
// Define the sub query
DBCommand subCmd = db.createCommand();
DBColumnExpr MAX_DATE_FROM = T_EDH.C_DATE_FROM.max().as(T_EDH.C_DATE_FROM);
subCmd.select(T_EDH.C_EMPLOYEE_ID, MAX_DATE_FROM);
subCmd.groupBy(T_EDH.C_EMPLOYEE_ID);
DBQuery Q_MAX_DATE = new DBQuery(subCmd);
// Define the query
DBCommand cmd = db.createCommand();
// Select requried columns
cmd.select(T_EMP.C_EMPLOYEE_ID, T_EMP.C_FULLNAME);
cmd.select(T_EMP.C_GENDER, T_EMP.C_PHONE_NUMBER);
cmd.select(T_DEP.C_DEPARTMENT_ID, T_DEP.C_NAME, T_DEP.C_BUSINESS_UNIT);
cmd.select(T_EMP.C_UPDATE_TIMESTAMP, T_DEP.C_UPDATE_TIMESTAMP);
// Set Joins
cmd.join(T_EDH.C_EMPLOYEE_ID, Q_MAX_DATE.findQueryColumn(T_EDH.C_EMPLOYEE_ID))
.where(T_EDH.C_DATE_FROM.is(Q_MAX_DATE.findQueryColumn(MAX_DATE_FROM)));
cmd.join(T_EMP.C_EMPLOYEE_ID, T_EDH.C_EMPLOYEE_ID);
cmd.join(T_DEP.C_DEPARTMENT_ID, T_EDH.C_DEPARTMENT_ID);
// Set Constraints
cmd.where(T_EMP.C_RETIRED.is(false));
// Set Order
cmd.orderBy(T_EMP.C_LASTNAME);
cmd.orderBy(T_EMP.C_FIRSTNAME);
// Query Records and print output
printQueryResults(cmd, conn);
// Define an updateable query