View Help

Reply

Join Date: Oct 2009
Posts: 1
Reputation: Moordoom is an unknown quantity at this point 
Solved Threads: 0
Moordoom Moordoom is offline Offline
Newbie Poster

View Help

 
0
  #1
Oct 28th, 2009
In the view below, I need the line "isnull(wwr.packed_qty, isnull((select sum(qty_on_hand) from lot_loc where item = coi.item and loc like 'P%'), 0)) packed_qty, " to include a "or 'S%'", so that both P and S are found, but I get a syntax error when I add it.
What is the correct syntax that I am missing?
This is what I used isnull(wwr.packed_qty, isnull((select sum(qty_on_hand) from lot_loc where item = coi.item and loc like 'P%' or 'S%'), 0)) packed_qty, and got the syntax at 'or' error.
Below is the whole "Current" view.


  1. CREATE VIEW [dbo].[SII_vwYardsOnHandDueRpt]
  2. AS
  3. SELECT isnull(wwr.greige_item, (SELECT top 1 item FROM item WHERE family_code = 'GREIGE' AND coi.item LIKE item.item + '%')) greige_item,
  4. isnull(wwr.greige_yds, 0) greige_yds,
  5. isnull(wwr.finished_item, (SELECT top 1 item FROM item WHERE family_code = 'FINISHED' AND coi.item LIKE item.item + '%')) finished_item,
  6. isnull(wwr.finished_yds, 0) finished_yds,
  7. isnull(wwr.packed_item, coi.item) packed_item,
  8. isnull(wwr.packed_desc, it.description) packed_desc,
  9. isnull(wwr.packed_qty, isnull((SELECT sum(qty_on_hand) FROM lot_loc WHERE item = coi.item AND loc LIKE 'P%'), 0)) packed_qty,
  10. isnull(wwr.pack_uom, it.u_m) pack_uom,
  11. coi.co_num,
  12. coi.co_line,
  13. coi.co_release,
  14. coi.due_date,
  15. (coi.qty_ordered - coi.qty_shipped) * dbo.SIIItemSalesUOM2(coi.co_num, coi.co_line, coi.co_release) qty_due,
  16. coi.u_m sales_uom,
  17. ca.[name] customer_name,
  18. dbo._SIIQtyDueInYards(coi.co_num, coi.co_line, coi.co_release) qty_due_yds
  19. FROM coitem coi WITH(NOLOCK)
  20. INNER JOIN item it WITH(NOLOCK)
  21. ON it.item = coi.item
  22. LEFT OUTER JOIN co WITH(NOLOCK)
  23. ON co.co_num = coi.co_num
  24. LEFT OUTER JOIN custaddr ca WITH(NOLOCK)
  25. ON ca.cust_num = co.cust_num
  26. AND ca.cust_seq = co.cust_seq
  27. LEFT OUTER JOIN SII_vwWipWebReport wwr
  28. ON wwr.packed_item = coi.item
  29. WHERE co.stat IN ('O', 'S')
  30. AND coi.stat IN ('O', 'S')
Last edited by Ezzaral; Oct 28th, 2009 at 3:51 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,464
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 629
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
0
  #2
Oct 29th, 2009
and (loc like 'P%' or loc like 'S%')
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 315 | Replies: 1
Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC