Someone may help you here (I hope they do) but the SQL Query experts live @ http://groups.yahoo.com/group/SQLQueriesNoCode That group may get you an answer faster.
At 11:16 AM 9/23/2004, you wrote: >Hello, > > > >I hope this makes sense. > > > >This is really a SQL question but I was hoping someone could help me. I >need to select the next record in a table. I have an order line item table >which has detail records for a bunch of orders. > > > >So basically I need all the records in the detail table that are for a >particular order number but I don't know the next order number until I >select the records from the same table. I've tried nested subqueries and >joins but cannot seem to get the query to come out correctly. > > > >This query returns the record I need. If the Top 1 is removed it returns >about 50,000 records. Which I only need all the line items for one order at >a time. > > > >Select Top 1 * from PT_Line as t1, PT_Line as t2 where > >(t1.PT_Line_Pick_Loc = 'GQ') and (t1.PT_Line_Stop_Pick is null) and >(t1.PT_Line_Item_ReSale is null) > > > > > >Now I need all the records in the same table where the order number matches >the order number in the above query. > > > >Select * from PT_Line as t2 where t2.PT_Line_Order_No = (Select Top 1 * from >PT_Line as t1, PT_Line as t2 where > >(t1.PT_Line_Pick_Loc = 'GQ') and (t1.PT_Line_Stop_Pick is null) and >(t1.PT_Line_Item_ReSale is null)) > > > > > >Any help would be appreciated. ---------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.767 / Virus Database: 514 - Release Date: 9/21/2004 [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
