Have a current query which all works fine but I've been asked to add more data but only very select data. Current query looks like this:SELECT actions.partnumber, actions.outsqty, actions.comment, actions.bomcomment, stock.desc1, stock.desc2, stock.desc3, stock.desc4, actions.duedate, stock.supplier, stock.stdcost, stock.alias01, stock.alias02, stock.alias03FROM stock, actionsWHERE stock.partnumber = actions.partnumberORDER BY actions.partnumber, actions.duedate
Now the problem I have is the extra data I've been asked to pull in is in another table (the plines table).Which with my rough workings now looks like this:SELECT actions.partnumber, actions.outsqty, actions.comment, actions.bomcomment, stock.desc1, stock.desc2, stock.desc3, stock.desc4, actions.duedate, stock.supplier, stock.stdcost, stock.alias01, stock.alias02, stock.alias03, plines.pordno, plines.plineno, plines.qty, plines.duedate AS Expr1, plines.price, plines.enteredbyFROM stock, actions, plinesWHERE stock.partnumber = actions.partnumber AND actions.partnumber = plines.partnumberORDER BY actions.partnumber, actions.duedate
Which is all fine but the problem I'm having is they only want to see the last 3 entries in plines.pordno, and the relevant data in the rest on the plines table, for each partnumber.Now I think the the TOP function might be the best to use as MAX would only show me one line but I have no idea how to implement it in the query.Probably not the best worded question but any help gratefully received. Thanks!