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
jon@a.com
art@b.com
Then I have a table, called UPLOAD_HISTORY. Sample data:
EMAIL FILETYPE FILENAME
jon@a.com 1 file1.txt
jon@a.com 2 filex.txt
jon@a.com 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
jon@a.com 1 file1.txt
jon@a.com 2 filex.txt
3
jon@a.com 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
jon@a.com 1 file1.txt 1
jon@a.com 2 filex.txt 1
jon@a.com 3 0
jon@a.com 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
jon@a.com 1 file1.txt 1
jon@a.com 2 filex.txt 1
jon@a.com 3 0
jon@a.com 4 fileb.txt 1
art@b.com 1 0
art@b.com 2 0
art@b.com 3 0
art@b.com 4 0
However, I could ask for just File Type 1:
EMAIL FILETYPE FILENAME STATUS
jon@a.com 1 file1.txt 1
art@b.com 1 0
Thanks