Queennie L
asked on
Join 2 tables and create date columns
Hello Experts,
I have 2 SQL tables A and B.
A table has all the dates in "Date" column.
B table has different values in "CodeNo" column.
What I want to output is join "Date" column in A table to B table.
Create "Date_1" column for the first "CodeNo" if then create another "Date_2" column for the rest of the values in "Date" column in A table.
Is this possible?
Thank you for all your help.
Join-2-tables-A-and-B.xlsx
I have 2 SQL tables A and B.
A table has all the dates in "Date" column.
B table has different values in "CodeNo" column.
What I want to output is join "Date" column in A table to B table.
Create "Date_1" column for the first "CodeNo" if then create another "Date_2" column for the rest of the values in "Date" column in A table.
Is this possible?
Thank you for all your help.
Join-2-tables-A-and-B.xlsx
ASKER
@TomasHelgi:
My problem is I cannot make it to create a new column.
Thank you for your help.
My problem is I cannot make it to create a new column.
Thank you for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@slightwv:
I will test it and let you know.
Thank you again for your help.
I will test it and let you know.
Thank you again for your help.
ASKER
@slightwv:
When I run this code, there is an error mydate and codeno invalid column names.
Thank you.
When I run this code, there is an error mydate and codeno invalid column names.
Thank you.
ASKER
@slightwv:
It is my fault. I invert 2 tables in the wrong place.
It is my fault. I invert 2 tables in the wrong place.
ASKER
@slightwv:
OMG! It is working.
Thank you for sharing your expertise and intelligence.
I really appreciate it.
Thank you also those who give their input.
OMG! It is working.
Thank you for sharing your expertise and intelligence.
I really appreciate it.
Thank you also those who give their input.
Happy to help!
The example data you provide tells me that the table B lacks some additional columns and data so
that you can do some simple SQL joins. I personally would have the date column in table B.
That would give you ability to use GROUP BY on STNo,InSNo and CodeNo columns and group the relevant dates together for further data manipulation.
Regards,
Tomas Helgi