|
-
Jun 1st, 2000, 05:28 AM
#1
Thread Starter
Addicted Member
CREATE TABLE #WorkingData
(
receipt_id int
,receipt_item_id int
,fulfillment_type_id int
,created_dt smalldatetime
)
INSERT INTO #WorkingData
(order_id
,item_id
,vendor_id
,created_dt)
(SELECT order_id, item_id, vendor_id, created_dt
FROM database1.dbo.vw_table
WHERE created_dt < dateadd(mi, -61, getdate())
AND vendor_id IN (0, 15, -1000, -1015))
SELECT Distinct wd.order_id, wd.item_id, wd.vendor_id, w.vendor_id, wd.created_dt
FROM #WorkingData wd
JOIN #WorkingData w
ON wd.item_id = w.item_id
--WHERE w.vendor_id IN (0, 15)
I am trying to get a result back that will give me
order_id, item_id, vendor_id (positive number), vendor_id (negative number), created_dt
Help.
I need to do a self join?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|