PS QUery
Forum » Forum / Help » PS QUery
Started by: Kevin (guest)
On: 1273790500|%e %b %Y, %H:%M %Z|agohover
Number of posts: 2
rss icon RSS: New posts
Summary:
How do I use sub-query in the selected column in PS Query
PS Query
Kevin (guest) 1273790500|%e %b %Y, %H:%M %Z|agohover

How do I create a PeopleSoft Query to place a sub-query in the selected column?
For example, how do I convert the followign SQL into PS Query?

select a.business_unit,
       a.voucher_id,
       b.voucher_line_num,
       sum(a.saletx_amt),
       sum(b.saletx_calc_amt)
       (select sum(bb.saletx_calc_amt)
          from ps_voucher_line bb
         where bb.business_unit = a.business_unit
           and bb.voucher_id    = a.voucher_id) Sum_Calc_Sales_Tax_AllLines,
       sum(a.saletx_amt) - (select sum(bbb.SALETX_CALC_AMT)
                              from ps_voucher_line bbb
                             where bbb.business_unit = a.business_unit
                               and bbb.voucher_id    = a.voucher_id) Over_Under_STX_PYMT,
  from ps_voucher      a,
       ps_voucher_line b
 where a.business_unit = '7012'
   and a.voucher_id    = '01677751'
   and b.business_unit = a.business_unit
   and b.voucher_id    = a.voucher_id
group by a.business_unit,a.voucher_id,b.voucher_line_num
having sum(a.saletx_amt) <> (select sum(bbb.saletx_calc_amt)
                               from ps_voucher_line bbb
                              where bbb.business_unit = a.business_unit
                                and bbb.voucher_id    = a.voucher_id)
order by 1,2,3;
Last edited on 1273986164|%e %b %Y, %H:%M %Z|agohover By Praj + Show more
Reply  |  Options
Unfold PS Query by Kevin (guest), 1273790500|%e %b %Y, %H:%M %Z|agohover
Re: PS Query
PrajPraj 1273986136|%e %b %Y, %H:%M %Z|agohover

Hi, you can't use sub-selects in PS Query so the easiest way to put this into PS Query would be to create a view and then reference that view.

Alternatively, you could look at using embedded SQL in your PSQuery which involves passing SQL through the %SQL meta-sql construct to a query as explain in the article link.

Reply  |  Options
Unfold Re: PS Query by PrajPraj, 1273986136|%e %b %Y, %H:%M %Z|agohover
New Post
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License