I don't know if this is even possible or perhaps my database is designed poorly and I could have done it a better way?
Anyway here goes, I have database with two tables as follows "General Data
" and "Assessment Data
" - they're set up so that a patient can have a few basic details entered into "General Data" and then each time they have an assessment they have data relevant to that assessment entered into the "Assessment Data" table
Sorry about the dodgy formatting! Not enough reputation points to upload images :(
General Data
**ID -- Age (Years) -- Gender -- Town ------ Referral Source -- Referral Doctor's Name**
1---- 12---------------- Male-------- Batlow----- GP Referral---------- Smith
2---- 13---------------- Male --------Coolamon- GP Referral ---------Bobby
Assessment Data
**ID -- Date of Assessment ----- Height (cm) ----- Weight (kg)**
1---- 6/12/2012-------------------- 100-------------------- 80
1---- 13/12/2012------------------ 100-------------------- 85
2---- 25/12/2012 ------------------200-------------------- 90
2---- 28/12/2012------------------ 200 ------------------- 90
What i would like to do is create a query that will create something like the following
Query?
**ID - - Height 1 - - Weight 1 - - Height 2 -- Weight 2 - - Height 3 - - Weight 3 etc...**
1 - - 100 - - - - - - - 80 - - - - - - - 100 - - - - - 85 - - - - - - - - - - - - - - - - - - - - - - -
2 - - 200 - - - - - - - 90 - - - - - - - 200 - - - - - 90 - - - - - - - - - - - - - - - - - - - - - - -
I've had a bit of a play around with a concatenating function and query that i found on another forum but it wasn't suitable for what i wanted to do
Any help or even pointing me in the right direction would be great!
Try this:
You will need to use a couple of crosstab queries to acheive this.
First you need to sequence the "Assessment Data" table by using the following query and putting the results into a temporary table called "Temp_AssessmentData".
Then you can use this temporary table in two sub queries, one to get the weight values and another to get the height.
qAssessmentData_Weight
qAssessmentData_Height
You can then join these two sub queries together to then get your required query