-
no value
I have two tables, the first has daily information such as the date and shift. the second has recorded downtimes. both are joined with a unique ID. what I'm after is to list the dates and if there was downtime then show it, if no downtime entered that day then show a "0". is there a function or statement that will pick the value and if there was no entries for that day give me the date and a 0?
-
ok, here's what my tables have-
Production Table |
|
|
Downtime Table |
|
enter shift |
Production_Date |
|
DailyProdID |
Length |
700 |
6/1/2015 |
|
707 |
15 |
701 |
6/1/2015 |
|
707 |
30 |
702 |
6/2/2015 |
|
700 |
60 |
703 |
6/3/2015 |
|
700 |
45 |
704 |
6/3/2015 |
|
|
|
705 |
6/4/2015 |
|
|
|
706 |
6/5/2015 |
|
|
|
707 |
6/5/2015 |
|
|
|
708 |
8/6/2015 |
|
|
|
715 |
8/11/2015 |
|
|
|
716 |
8/11/2015 |
|
|
|
717 |
8/11/2015 |
|
|
|
what i'm trying to get is-
Production Table |
|
|
enter shift |
Production_Date |
Length |
700 |
6/1/2015 |
105 |
701 |
6/1/2015 |
0 |
702 |
6/2/2015 |
0 |
703 |
6/3/2015 |
0 |
704 |
6/3/2015 |
0 |
705 |
6/4/2015 |
0 |
706 |
6/5/2015 |
0 |
707 |
6/5/2015 |
45 |
708 |
8/6/2015 |
0 |
715 |
8/11/2015 |
0 |
716 |
8/11/2015 |
0 |
717 |
8/11/2015 |
0 |
-
Do an outer join, show all values in the production table and the missing one in tDowntime.
run another query on that one with NZ to convert the nulls to zero
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules