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?

Perk8
  • 63
  • 1
  • 8
  • I'm trying to grab the last two characters from the poh1_g1 column. – Perk8 Sep 20 '22 at 16:51
  • 1
    With explicit cast to string: `RIGHT(purchase_order_history.poh1_gl::TEXT, 2) AS "Dept",` – Lukasz Szozda Sep 20 '22 at 16:53
  • right is an function. You can have many ways query function signature (input,output). see https://stackoverflow.com/questions/1347282/how-can-i-get-a-list-of-all-functions-stored-in-the-database-of-a-particular-sch – jian Sep 20 '22 at 17:08
  • 1
    Right() is a string function, not a numerical function. – Frank Heikens Sep 20 '22 at 17:24
  • @Perk8 What do you mean by "*the last two characters*" from a `numeric` value? – Bergi Sep 20 '22 at 19:19

0 Answers0