Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 View

Author  Topic 

brandonbiz
Starting Member

2 Posts

Posted - 2005-03-13 : 16:00:25
Hi,
I am trying to create a view that is used to send FedEx information for shipping labels. I want to look in the invoice table see what the ship_code is, then determine which address to use.

If the ship_code is 0 I need to use the address code in the bill_code field.
If the ship_code is >0 that is the address code I need to use.

This is close to what I want.........
I need to get the invoice_id and the "CODE" (either ship_code or Bill_code if ship_code is 0)

SELECT INVOICES_ID, SHIP_CODE, BILL_CODE
FROM dbo.INVOICES
WHERE (SHIP_CODE > 0) OR
(SHIP_CODE = 0) AND (NOT (SHIP_CODE IN
(SELECT ship_code
FROM dbo.invoices
WHERE ship_code > 0)))
ORDER BY INVOICES_ID


Any ideas on how I can get the Invoice_id and "code" which I can then use to get the shipping information from the address table.

Thank you so much for any help you can give me,

Christine

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-03-13 : 16:08:44
will this do it?

select invoices_id, isNull( ifNull(ship_code,0), bill_code) as code from invoices order by invoices_id

Be One with the Optimizer
TG
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-13 : 16:15:49
it's nullif not ifnull, TG

Go with the flow & have fun! Else fight the flow
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-03-13 : 16:19:50
Doi! Thanks...

select invoices_id, isNull( nullIf(ship_code,0), bill_code) as code from invoices order by invoices_id


Be One with the Optimizer
TG
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-03-13 : 16:21:34
Spirit1, it's Sunday and you're only 25, shouldn't you be nursing a hangover or something instead of perusing sqlteam.com?

Be One with the Optimizer
TG
Go to Top of Page

brandonbiz
Starting Member

2 Posts

Posted - 2005-03-13 : 16:25:08
Perfect
That's it.

Thank you so very much,
Christine


Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-13 : 16:35:58
i wish... have an exam tommorow and i'm taking a learning break...

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -