• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

19. Some Common Data Manipulation Problems > 19.5. Time to Completion I

Time to Completion I

Here is a simple time-to-completion problem. Table 19-8 shows the status of widget production for your company. At various stages in the production process, the workers enter a record into the table indicating the remaining time to completion for the widget.

Table 19-8. Widgets table: Time to completion for widgets

WidgetID

TimeToCompletion

1

5

1

3

1

2

1

1

2

6

2

3

2

0

3

8

3

7

3

6

3

4

4

9

4

4

4

2

4

0

We want to identify those widgets that are not yet completed.

Solution

The next SQL statement does the job. Note the use of the NOT IN form of subquery, which is discussed in Section 6.7.10 in Chapter 6.

SELECT DISTINCT WidgetID FROM Widgets As W1
WHERE 0 NOT IN
(SELECT TimeToCompletion FROM Widgets As W2
WHERE W2.WidgetID = W1.WidgetID)

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint