Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Posts
    5

    Unanswered: how to get the quantity from output of sql query command

    I want to know how to get the quantity from output of sql query command

    for example, I could get the container name by below command

    select container_name from sysibmadm.snapcontainer

    get the container number by

    select TBSP_NUM_CONTAINERS from SYSIBMADM.SNAPTBSP_PART

    now I want to get the container number by below command output result
    select container_name from sysibmadm.snapcontainer
    so what more command should I add on above command, I mean I want to get the container number by container name from the output of above command, not by 'join'.
    Thank you in advance.

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Why did you posted same issue in other forums?

    Quote Originally Posted by quchangl View Post
    I want to know how to get the quantity from output of sql query command

    for example, I could get the container name by below command

    select container_name from sysibmadm.snapcontainer

    get the container number by

    select TBSP_NUM_CONTAINERS from SYSIBMADM.SNAPTBSP_PART

    now I want to get the container number by below command output result
    select container_name from sysibmadm.snapcontainer
    so what more command should I add on above command, I mean I want to get the container number by container name from the output of above command, not by 'join'.
    Thank you in advance.
    Quote Originally Posted by quchangl View Post
    I want to know how to get the quantity from output of sql query command

    for example, I could get the container name by below command

    select container_name from sysibmadm.snapcontainer

    get the container number by

    select TBSP_NUM_CONTAINERS from SYSIBMADM.SNAPTBSP_PART

    now I want to get the container number by below command output result
    select container_name from sysibmadm.snapcontainer
    so what more command should I add on above command, I mean I want to get the container number by container name from the output of above command, not by 'join'.
    Thank you in advance.

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Use isolation level REPEATABLE READ, run the query twice and fetch all the rows. Then you can do the counting in your client application first and the 2nd query execution is used to get the actual values. But this is usually the dumbest approach - instead, you should think about not relying on a total row count at all. There are rarely cases where you need an exact count on big result sets (and on small result sets it is a no-brainer anyway).

    Alternatively, have a look at the ROW_COUNT() and COUNT() functions.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •