Perhaps someone can assist with designing a query to meet these requirements. I'm going to need this to be part of an inline view which will be joined to a larger query.
I have the basic table of email addresses:
EMAIL
[email protected]
[email protected]
Then I have a table, called UPLOAD_HISTORY. Sample data:
EMAIL FILETYPE FILENAME
[email protected] 1 file1.txt
[email protected] 2 filex.txt
[email protected] 4 fileb.txt
Then there is the table of file types:
FILE ID FILE TYPE
1 TYPE A
2 TYPE B
3 TYPE C
4 TYPE D
If I perform a query, and outer join the UPLOAD_HISTORY and FILE_TYPES, I would get something like this:
EMAIL FILETYPE FILENAME
[email protected] 1 file1.txt
[email protected] 2 filex.txt
3
[email protected] 4 fileb.txt
What I need for the missing record, is to fill in the missing values from the UPLOAD_HISTORY table. My ideal result set would look like this:
EMAIL FILETYPE FILENAME STATUS
[email protected] 1 file1.txt 1
[email protected] 2 filex.txt 1
[email protected] 3 0
[email protected] 4 fileb.txt 1
I am looking to get all file types, an email for every line, and a status of 1 if there is a record for that file type, or 0 if there is not........
Sometimes there may be criteria passed. I may ask for a specific file type, or not.
If a particular email does not have any entries in the UPLOAD_HISTORY table, is it possible to get empty records?
EMAIL FILETYPE FILENAME STATUS
[email protected] 1 file1.txt 1
[email protected] 2 filex.txt 1
[email protected] 3 0
[email protected] 4 fileb.txt 1
[email protected] 1 0
[email protected] 2 0
[email protected] 3 0
[email protected] 4 0
However, I could ask for just File Type 1:
EMAIL FILETYPE FILENAME STATUS
[email protected] 1 file1.txt 1
[email protected] 1 0
Thanks
Left join from file types to history: