Question: I have two separate data tables I need a sql query to pull data out of . The first table is called Collected _ Details

I have two separate data tables I need a sql query to pull data out of.
The first table is called Collected_Details and containsa DC_ID column and a Collection_ID column. The DC_ID column contains the names of completed text entryforms and the Collection_ID column contains unique ID numbers generated each time a text entry form has data entered into it.
The second table is called Sample_Details and contains a Collection_ID, DCE_ID, Val and Performed_Date columns.The Collection_ID column contains the unique IDs generated from the Collected_Details table. The DCE_ID column containsnames of the entries and the Val column contains the values inputted for those entries. The Performed_DateColumn marks when the entry form was completed.
The sql query needs to have a search field for the DC_ID column from theCollected_Details table. The DC_ID values that will be searched for are (Gummy_Worm, Gummy_Bear, Taffy).Based on the name searched for in the DC_ID column, the query needs to pull out each associated ID number generated from the Collection_ID column. It then needs to take those Collection_ID numbers and search for them in the Sample_Details table Returning the values from the DCE_ID, Val and Performed_Date Columns. Data returned should be ordered by most recent performed date to least recent.
Below is the code i currently have; however it does not work. I am receiving "invalid identifier errors"
SELECTsd.DCE_ID,sd.Val,sd.Performed_Date FROM Sample_Details WHERE sd.Collection_ID IN( SELECT cd.Collection_IDFROM Collected_Details cdWHERE sd.DC_ID IN ('CDA_SAMPLE_SUMMARY', 'LN2_SAMPLE_SUMMARY', 'HPO2_SAMPLE_SUMMARY')) ORDER BY sd.Performed_Date DESC;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!