you have an 'openWin' function, but then you're trying to add inline JS to do the same thing. I assume that later on you're looping over your 'foo' query outputting these links to renew. In which case I'd want to simply pass either a URL or just the ID into the openWin function. Much simpler than trying to add dynamic JS into a query cell.
I'm slightly confused as well why you're creating a new query, foo, when you already have the query getOrderHist which seems to have everything you need.
function openWin(id) {
window.open("detail.cfm?id=" + id, "_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
}
<cfoutput query="getOrderHist">
ID: #getOrderHist.id_int#<br>
aNo: #getOrderHist.aNo_var#<br>
<a href="" onclick="openWin(#getOrderHist.id_int#); return false;">Renew</a><br>
</cfoutput>