Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Can you please help me?? Expand / Collapse
Author
Message
Posted Wednesday, July 3, 2013 4:14 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 11:15 AM
Points: 824, Visits: 2,655
Code To Simulate OP's Table:
CREATE TABLE customer (C_recid INT);

INSERT INTO customer VALUES (50200),(50194),(50430),(50191),(1);

Here is my solution:
DECLARE @Lookup TABLE (C_recid INT, OrderSeq SMALLINT);
INSERT INTO @Lookup VALUES (50200, 1), (50194, 2), (50430, 3), (50191, 4), (1, 5);

SELECT
c.*
FROM
customer c
INNER JOIN
@Lookup l
ON c.C_recid = l.C_recid
ORDER BY
l.OrderSeq;





The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1469969
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse