Beginning Databasees with PostgreSQL -- CAST
Hello,
I have a question about the use of CAST. For example, look at the SELECT statement on page 195:
===========================================
SELECT i.item_id, i.cost_price, s.quantity
FROM item i LEFT OUTER JOIN stock s
ON i.item_id=s.item_id AND s.quantity>2
WHERE i.cost_price>CAST(5.0,NUMERIC(7,2));
===========================================
The following seems to work just as well and gives the same result:
===========================================
SELECT i.item_id, i.cost_price, s.quantity
FROM item i LEFT OUTER JOIN stock s
ON i.item_id=s.item_id AND s.quantity>2
WHERE i.cost_price>5.0;
===========================================
Why is the CAST needed?
|