sql="select Top " + PageSize + " x.* from I_ToolPlan x where WTPROD between '"+a+"' and '"+b+"' left join (select top "+PageSize*CurrentPage+" a.WTPROD,a.WTTOOL from I_ToolPlan a where a.WTPROD between '"+a+"' and '"+b+"' order by WTPROD desc)y on x.WTPROD=y.WTPROD and x.WTTOOL=y.WTTOOL where y.WTPROD is null order by x.WTPROD desc ";
WTPROD between '"+a+"' and '"+b+"' 放在 where后面WTPROD改為x.WTPROD
sql="select Top " + PageSize + " x.* from I_ToolPlan x left join (select top "+PageSize*CurrentPage+" WTPROD,WTTOOL from I_ToolPlan where WTPROD between '"+a+"' and '"+b+"' order by WTPROD desc)y on x.WTPROD=y.WTPROD and x.WTTOOL=y.WTTOOL where x.WTPROD between '"+a+"' and '"+b+"' and y.WTPROD is null order by x.WTPROD desc ";
select Top " + PageSize + " x.* from I_ToolPlan x left join (select top "+PageSize*CurrentPage+" WTPROD,WTTOOL from I_ToolPlan where WTPROD between '"+a+"' and '"+b+"' order by WTPROD desc)y on x.WTPROD=y.WTPROD and x.WTTOOL=y.WTTOOL where x. WTPROD between '"+a+"' and '"+b+"' and y.WTPROD is null order by x.WTPROD desc "
sql="select Top " + PageSize + " x.* from I_ToolPlan x where WTPROD between '"+a+"' and '"+b+"' left join (select top "+PageSize*CurrentPage+" a.WTPROD,a.WTTOOL from I_ToolPlan a where a.WTPROD between '"+a+"' and '"+b+"' order by WTPROD desc)y on x.WTPROD=y.WTPROD and x.WTTOOL=y.WTTOOL where y.WTPROD is null order by x.WTPROD desc ";
from I_ToolPlan x
left join (select top "+PageSize*CurrentPage+" WTPROD,WTTOOL from I_ToolPlan where WTPROD between '"+a+"' and '"+b+"' order by WTPROD desc)y on x.WTPROD=y.WTPROD and x.WTTOOL=y.WTTOOL
where x. WTPROD between '"+a+"' and '"+b+"' and y.WTPROD is null
order by x.WTPROD desc "