![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Suppose I have a table like: ITEM * DESCRIPTION * LOCATION * * * * BIN 1234 * *RED LAMP * * * WAREHOUSE * *CL32 1234 * *RED LAMP * * * STOREROOM * *FLOOR 3456 * *TABLE * * * * * * * WAREHOUSE * *XL23 4231 * CHAIR * * * * * * * * STOREROOM * *M233 I have a query like: SELECT ITEM, DESCRIPTION, LOCATION, BIN FROM <TABLE However if there are more than one location for the ITEM I want the WAREHOUSE location For example I only want to return: 1234 * *RED LAMP * * * WAREHOUSE * *CL32 3456 * *TABLE * * * * * * * WAREHOUSE * *XL23 4231 * CHAIR * * * * * * * * STOREROOM * *M233 Any ideas? |
#3
| |||
| |||
|
|
Suppose I have a table like: ITEM DESCRIPTION LOCATION BIN 1234 RED LAMP WAREHOUSE CL32 1234 RED LAMP STOREROOM FLOOR 3456 TABLE WAREHOUSE XL23 4231 CHAIR STOREROOM M233 I have a query like: SELECT ITEM, DESCRIPTION, LOCATION, BIN FROM<TABLE However if there are more than one location for the ITEM I want the WAREHOUSE location |
|
For example I only want to return: 1234 RED LAMP WAREHOUSE CL32 3456 TABLE WAREHOUSE XL23 4231 CHAIR STOREROOM M233 Any ideas? |
#4
| |||
| |||
|
|
On 10.10.2011 23:14, cburs... (AT) geusnet (DOT) com wrote: Suppose I have a table like: ITEM * DESCRIPTION * LOCATION * * * * BIN 1234 * *RED LAMP * * * WAREHOUSE * *CL32 1234 * *RED LAMP * * * STOREROOM * *FLOOR 3456 * *TABLE * * * * * * * WAREHOUSE * *XL23 4231 * CHAIR * * * * * * * * STOREROOM * *M233 I have a query like: SELECT ITEM, DESCRIPTION, LOCATION, BIN FROM<TABLE However if there are more than one location for the ITEM I want the WAREHOUSE location What if there is more than one location but no WAREHOUSE location? For example I only want to return: 1234 * *RED LAMP * * * WAREHOUSE * *CL32 3456 * *TABLE * * * * * * * WAREHOUSE * *XL23 4231 * CHAIR * * * * * * * * STOREROOM * *M233 Any ideas? See Joel's reply. Kind regards * * * * robert -- remember.guy do |as, often| as.you_can - without endhttp://blog.rubybestpractices.com/ |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
I realize this is a very simplified example for a more complex query. I do not understand how the table creation and data loading commands will help. *Am I missing something? |
#7
| |||
| |||
|
|
For example I only want to return: 1234 RED LAMP WAREHOUSE CL32 3456 TABLE WAREHOUSE XL23 4231 CHAIR STOREROOM M233 Any ideas? |
#8
| |||
| |||
|
|
On Oct 11, 7:23*am, cburs... (AT) geusnet (DOT) com wrote: I realize this is a very simplified example for a more complex query. I do not understand how the table creation and data loading commands will help. *Am I missing something? Yes. If it is easy for people to set up a test example, then they can try it and play with it rather than guess or ignore it (most will ignore it). *It also means you can better determine whether your simplification makes sense as you see what you haven't told people. The correct answer is, of course, normalize your design. *If for whatever reason you are stuck with it, usually a sql answer will be the best, although that assumes at least third normal form. *If you can't do SQL, use PL/SQL. *Other languages would be below that. *(I'm stuck with a 4GL that often fights with oracle, by assuming version 7. *When I see problem statements like "There will always be at least one location which will be either Warehouse or Storeroom." I have to question how that is enforced. *Enterprise inventory systems will often have strange requirements.) A distinct often leads to a sort, so if it can be avoided, that is usually better. *The merits of ansi versus oracle style join syntax are debatable, but you might want to watch for version-dependent bugs. jg -- @home.com is bogus.http://www.technewsworld.com/story/c...ary/73432.html |
#9
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |