iif question

scott1742

New Member
Joined
Aug 19, 2011
Messages
3
My query is returning incorrect column expression.
it is centered around the iif statement area. Is my syntax in error?
I can pull the iif statement and the query runs fine.

SELECT '687547' AS 'Divison ID', '018502' AS 'Customer ID', po_hdr.po_no, po_hdr.date_created AS 'po date', po_line.qty_ordered AS 'Quantity', po_line.unit_of_measure AS 'UOM', po_line.required_date AS 'Requested ship date', inventory_supplier.supplier_part_no, address.mail_address1 AS 'ANSI SCAC',

iif(po_hdr.location_id = 101 and len(po_hdr.ship2_name) = 0, 05,
iif(po_hdr.location_id = 104 and len(po_hdr.ship2_name) = 0, 02,
iif(po_hdr.location_id = 102 and len(po_hdr.ship2_name) = 0, 01,
iif(po_hdr.location_id = 105 and len(po_hdr.ship2_name) = 0, 04,
iif(po_hdr.location_id = 107 and len(po_hdr.ship2_name) = 0, 03,
iif(po_hdr.location_id = 101 and len(po_hdr.ship2_name) = 0, 05,
"DS")))))) as 'ship code',


po_hdr.ship2_name, po_hdr.ship2_add1, po_hdr.ship2_add2, po_hdr.ship2_city, po_hdr.ship2_state, po_hdr.ship2_zip, po_hdr.ship2_country, po_hdr.po_desc AS 'free form text', inv_mast.item_id
FROM Prophet21_Live.dbo.address address, Prophet21_Live.dbo.inv_mast inv_mast, Prophet21_Live.dbo.inventory_supplier inventory_supplier, Prophet21_Live.dbo.po_hdr po_hdr, Prophet21_Live.dbo.po_line po_line
WHERE po_line.po_no = po_hdr.po_no AND po_line.inv_mast_uid = inventory_supplier.inv_mast_uid AND po_hdr.supplier_id = inventory_supplier.supplier_id AND po_line.inv_mast_uid = inv_mast.inv_mast_uid AND po_hdr.carrier_id = address.id AND ((po_hdr.supplier_id=$10987) AND (po_hdr.date_created>getdate()-60) AND (po_hdr.delete_flag='n') AND (po_line.complete='n') OR (po_hdr.supplier_id=$45094) AND (po_hdr.date_created>getdate()-60) AND (po_hdr.delete_flag='n') AND (po_line.complete='n'))
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top