Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select question
Message
From
31/05/2003 11:01:15
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00794865
Message ID:
00794870
Views:
10
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform