Customized getdata() query

:+1: 
@jegelstaff This PR is good to review. For some lines of code, I don't know why the indentation looks weird on github, the indentation does look fine locally.