0
SELECT DISTINCT
    purchase_order_master.po1_num AS "PO #", 
    RIGHT(purchase_order_history.poh1_gl, 2) AS "Dept",
    purchase_order_history.poh1_gl,
    purchase_order_master.po1_podate AS "PO Date", 
    purchase_order_history.poh1_gl AS "GL Account #", 
    purchase_order_master.po1_dept, 
    purchase_order_master.po1_vname AS "Vendor Name", 
    purchase_order_master.po1_vnum AS "Vendor Number"
    
FROM
    purchase_order_master
    INNER JOIN
    purchase_order_line_items
    ON 
        purchase_order_master.po1_num = purchase_order_line_items.po2_num AND
        purchase_order_master.po1_arid = purchase_order_line_items.po2_arid
    INNER JOIN
    purchase_order_history
    ON 
        purchase_order_line_items.po2_num = purchase_order_history.poh1_ponum AND
        purchase_order_line_items.po2_arid = purchase_order_history.poh1_arid
ORDER BY
 "PO Date" DESC;

Gives error:

ERROR: function right(numeric, integer) does not exist LINE 3: RIGHT(purchase_order_history.poh1_gl, 2) AS Dept, ^ HINT: No function matches the given name and argument types. You might need to add explicit type >casts.

Do I need to change the column values before I try?

5
  • I'm trying to grab the last two characters from the poh1_g1 column. Commented Sep 20, 2022 at 16:51
  • 1
    With explicit cast to string: RIGHT(purchase_order_history.poh1_gl::TEXT, 2) AS "Dept", Commented Sep 20, 2022 at 16:53
  • right is an function. You can have many ways query function signature (input,output). see stackoverflow.com/questions/1347282/… Commented Sep 20, 2022 at 17:08
  • 1
    Right() is a string function, not a numerical function. Commented Sep 20, 2022 at 17:24
  • @Perk8 What do you mean by "the last two characters" from a numeric value? Commented Sep 20, 2022 at 19:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.