>Can the following be done:
>
>Table 1: PARTS
>Fields : PART_NO, and other
>
>Table 2: PARTSUSED
>Fields : PART_NO, QTY_USED, DATE_USED, and other fields
>
>I want to create a query of parts with sum qty used. But the trick is that I want the parts that have not been used during selected period would show in the query with qty equal to 0 (and not NULL).
>
>Example:
>
>select PART_NO, sum( QTY_USED) as qty_sum from PARTS ;
>left join PARTSUSED on PART_NO.PART_NO = PARTSUSED.PART_NO where (DateFilter)
>
>This query will have all parts in PARTS table but the QTY_SUM for those that don't have records in PARTSUSED will show as NULL. How can I make the NULL to be 0 (zero)?
>
>TIA.
select parts.PART_NO, sum( nvl(QTY_USED,0) ) as qty_sum ;
from PARTS ;
left join PARTSUSED on PARTs.PART_NO = PARTSUSED.PART_NO
where (DateFilter)
Cetin