November 30, 2017 at 11:53 am
I would like to get below 3 raw as result.
12 67 601006 1001072
12 67 605059 1001075
12 67 606722 1001083
Thanks
November 30, 2017 at 11:57 am
Problem. How does the query decide which row goes with which other row? You'll need some column that provides that guidance, that is not shown in your picture. The reason that I ask is that SQL Server does not have any inherent ORDER to a table. It's never guaranteed that a read of all the rows will occur in the exact same order they were inserted in. That's why we need to know. You may be able to use a datetime column that reflects the exact order you're showing us, but it would have to already exist, or get manually created.
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
November 30, 2017 at 12:02 pm
Based the guess that the JOIN is based on ASCENDING order on both sides on the coin, this'll be enough to get your way:
(Untested)
If not, then I'm not going to bother repeating myself and Steve again. 🙂
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
November 30, 2017 at 12:45 pm
Thank you.
That should work. Order is doesn't matter.
Thanks
November 30, 2017 at 12:49 pm
Thom A - Thursday, November 30, 2017 12:02 PMBased the guess that the JOIN is based on ASCENDING order on both sides on the coin, this'll be enough to get your way:WITH ACA AS (SELECT *,ROW_NUMBER() OVER (ORDER BY ACA) AS RNFROM YourTableWHERE ACA IS NOT NULL),MET AS (SELECT *,ROW_NUMBER() OVER (ORDER BY MET) AS RNFROM YourTableWHERE MET IS NOT NULL)SELECT *FROM ACAJOIN MET ON ACA.RN = MET.RN;(Untested)
If not, then I'm not going to bother repeating myself and Steve again. 🙂
Don't lose that crystal ball!
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply