avoid SQL where clause when querying full period of record