留言板

How to get distinct value based on year & month from date column using DQ

RAVI RAJAMANI,修改在6 年前。

How to get distinct value based on year & month from date column using DQ

Regular Member 帖子: 123 加入日期: 14-12-7 最近的帖子
Hi,

How to get distinct value based on year & month from date column(ex- Display date column) using Dynamic Query.

Regards,
Ravi
RAVI RAJAMANI,修改在6 年前。

RE: How to get distinct value based on year & month from date column using

Regular Member 帖子: 123 加入日期: 14-12-7 最近的帖子
Hi ,
Solution

DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
				xyz.class, PortalClassLoaderUtil.getClassLoader());

		dynamicQuery
				.setProjection(ProjectionFactoryUtil.distinct((ProjectionFactoryUtil
						.sqlProjection(
								"year(displayDate) as year , month(displayDate) as month",
								new String[] { "year", "month" }, new Type[] {
										Type.INTEGER, Type.INTEGER }))));



Regards,
Ravi R