[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: [sqr-users] Need Some help in a SQR Select



In your example, your SQL would not select any rows because no item has a 
total of 140.00.  Because you group by ITEM, it only checks the sums of 
rows with the same values for ITEM.

If  you had the following data, your SQL should return XYZ for the ITEM.

          ITEM        Balance Amt       Business Unit
Row1  XYZ         100.00                  ABC
Row2  LMN         125.00                  KLM
Row3  XYZ         40.00                   PPP

It would find the total of XYZ (rows 1 and 3) and select it because the sum 
is 140.00 and find the total of LMN (row 2) and not select it because it is 
125.00.  Those are the only two totals it would check.   In your example, 
each row has a different ITEM, so each sum would include only one row and 
none of them would be 140.

At 12:33 AM 12/8/2005, you wrote:
>Hello All,
>
>In my SQR, I am trying to select  a group of rows in PS  where the sum of
>the amounts match some dolor amt.
>Example.
>
>In PS ITEM table we have following fields.
>  ITEM
>Balance amt
>BUSINESS UNIT
>
>let us say I have the following values in that table
>
>       ITEM        Balance Amt       Business Unit
>Row1  XYZ         100.00                  ABC
>Row2     LMN            125.00                  KLM
>Rwo2  KKK         40.00             PPP
>
>in my SQR, I am trying to select row 1 and row 2 where the total of
>Balance amt is 140.00 here is my procedure
>
>Begin-Select
>item
>
>from ps_item HAVING sum(bal_amt) = 140
>group by    ITEM
>
>END-SELECT
>
>I am not fetching any row, I am expecting the SQL to iterate with in all
>rows where
>it addes some rows to itself and sees where the total equals 140.00
>
>any suggestions would be highly appreciated.
>
>Thanks
>Regards
>
>
>Kaz.
>
>
>
>-----------------------------------------
>The information transmitted is intended only for the person or entity
>to which it is addressed and may contain confidential and/or
>privileged material. Any review, retransmission, dissemination or
>other use of, or taking of any action in reliance upon, this
>information by persons or entities other than the intended recipient
>is prohibited. If you received this in error, please contact the
>sender and delete the material from any computer.
>
>
>_______________________________________________
>sqr-users mailing list
>sqr-users@sqrug.org
>http://www.sqrug.org/mailman/listinfo/sqr-users


Daniel Vandenberg
Administrative Computing
University of Wisconsin Oshkosh

Email :  vandberg@uwosh.edu 


_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users