Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: LennyKhiger
  • Order by date
  1. LennyKhiger

    Curious question

    This query tested by me today. Same result, online, cursor dosn't need. You can use it, if you want. with Persons (person_id, v) as ( select varchar('0001', 50), varchar('A1', 50) from sysibm.sysdummy1 union all select '0001', 'A3' from sysibm.sysdummy1 union all select '0002', 'A1' from...
  2. LennyKhiger

    Curious question

    Select p1.person_id, Min('(' || p1.v || ifnull(', ' || p2.v, '') || ifnull(', ' || p3.v, '') || ')') as V from persons p1 left join persons p2 On p1.person_id = p2.person_id and p2.v > p1.v left join persons p3 On p2.person_id = p3.person_id and p3.v > p2.v Group by...
  3. LennyKhiger

    Curious question

    Number of LEFT JOIN equal Maximum(depth) - 1 Lenny
  4. LennyKhiger

    Curious question

    Any problem has dozens solutions. Programmer has to find the best way to solve problem. One more solution. If you know depth for person (in our case could be 3) you can use very simple query: Select p1.person_id, '(' || p1.v || ifnull(', ' || p2.v, '') || ifnull(', ' || p3.v, '') || ')'...
  5. LennyKhiger

    Curious question

    Hi Larry ! Any client application manipulate the data faster then DB engine. But anyway you have to declare cursor inside of the application and fetch rows one by one. Therefore you can't make program without DB engine. But if you want to show the result immediately, you have no choice...
  6. LennyKhiger

    Curious question

    Correction: with Person_in (person_id, v) as ( select varchar('0001', 50), varchar('A1', 50) from sysibm.sysdummy1 union all select '0001', 'A2' from sysibm.sysdummy1 union all select '0001', 'A3' from sysibm.sysdummy1 union all select '0002', 'A1' from sysibm.sysdummy1 union all select...
  7. LennyKhiger

    Curious question

    In case if we have DB2 V9, we can use function rowno over() and Order by in Person_Seq step. If we have duplicates and Nulls we have to add Person_dst and change Person_Seq step. See bellow: with Person_in (person_id, v) as ( select varchar('0001', 50), varchar('A1', 50) from...
  8. LennyKhiger

    Curious question

    Hi Ties Blom ! How I know this is most generic solution for this kind of task. If you have duplicates for this two columns, or Nulls, it could make solution a bit different, but you have to think in same way. Lenny
  9. LennyKhiger

    Curious question

    This is solution. How I promissed. with Person_in (person_id, v) as ( select varchar('0001', 50), varchar('A1', 50) from sysibm.sysdummy1 union all select '0001', 'A2' from sysibm.sysdummy1 union all select '0001', 'A3' from sysibm.sysdummy1 union all select '0002', 'A1' from...
  10. LennyKhiger

    Curious question

    Dear LarrySteele ! For solving your problem you have to use recursive common table expression technique. This is the best way to solve your problem. I can create this query to you, but would be much better if you will learn about this before...
  11. LennyKhiger

    how to make a number deafult length of 9

    Solution: select right(digits(your_integer), 9) from sysibm.sysdummy1 Lenny

Part and Inventory Search

Back
Top