You can query for historical stocks by using yahoo.finance.historicaldata, which is an undocumented data table maintained by the community:
Try this on YQL console:
select * from yahoo.finance.historicaldata where symbol = "GOOG" and startDate = "2012-06-06" and endDate = "2013-01-01"
Be warned that since this is unofficial and not maintained by Yahoo, this query is somewhat unreliable...