troubleshooting Question

Paginate with SQL Server 2005 using ROW_NUMBER()

Avatar of joethermal
joethermal asked on
Microsoft SQL Server 2005PHP
7 Comments1 Solution360 ViewsLast Modified:
Hi, I would like to paginate a query that has a join ...I can get row numbers with ROW_NUMBER() with a single table like this...(image attached)

SELECT *
             FROM (SELECT ROW_NUMBER() OVER(ORDER BY order_no) AS
       rownum,order_no, supplier,product FROM scheme.inwards_goods) AS standard

but have been unable to do it on the query below (which has a join)

can anyone help... select.tiff
SELECT DISTINCT
ig.order_no
,ig.supplier 
,ig.warehouse
,ig.product
,ig.unit_code
,ig.long_description
,ig.transaction_ref
,ig.product_long_desc
,ig.qty_ordered
,ig.date_entered
,ig.date_required
,ig.status
,ig.country
,ig.qty_received
,ig.latest_receipt_date
,ig.comments
,ig.po_reference
,ig.memo1
,ig.memo2
,st.lead_time
,st.reorder_days
,st.safety_days
,st.min_stock_level
,st.physical_qty
,st.allocated_qty
,st.back_order_qty
FROM scheme.inwards_goods ig WITH (READUNCOMMITTED)
LEFT OUTER JOIN scheme.stockm st WITH (READUNCOMMITTED) ON (ig.product = st.product)
 WHERE  ig.warehouse !='dd' 
 AND ig.warehouse !='d' 
 AND ig.warehouse !='dx'
 ORDER BY ig.date_entered DESC
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros