package com.yihu.wlyy.repository.statistics;

import com.yihu.wlyy.entity.statistics.PopulationBase;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Iterator;
import java.util.List;

/**
 * Created by lyr on 2016/08/18.
 */
public interface PopulationBaseDao extends PagingAndSortingRepository<PopulationBase, String>, JpaSpecificationExecutor<PopulationBase> {

    @Query("select a.num from PopulationBase a where a.code = ?1 and a.year = (select max(b.year) from PopulationBase b where b.code = ?1)")
    int findPeopleNumByCode(String code);

    List<PopulationBase> findByYear(Integer year);
}
