February 2, 2015 at 7:10 pm
Hey guys, I am very new to SQL and have been struggling with the following challenge.
My data is currently setup in the following format:
Name__________Age______Gender_____Occupation
SmithMom1_____50________F_________Teacher
SmithDad1______48________M_________Doctor
SmithChild1_____16________M_________Student
SmithChild2_____14________F_________Student
SmithDog1______7________M_________Dog
SmithCat1______2________F_________Cat
JohnsonFamily1_null_______null_______family
JohnsonMom1___100_______F________Dead
JohnsonDad1____98________M________Retired
JohnsonChild1___65________M________Retired
I need to report in the following manner where the age of the Children only (where applicable, up to 4) becomes a new column header:
Name__________Age___Gender____Occupation____Child1Age_____Child2Age_____Child3Age_____Child4Age
SmithFamily_____null_____null_____family__________16__________14
JohnsonFamily___null_____null_____family__________66
Any advice on how to accomplish this?
Viewing 0 posts
You must be logged in to reply to this topic. Login to reply