View Single Post
  #1 (permalink)  
Old June 15th, 2003, 10:59 AM
paulsen paulsen is offline
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?