question

SQL-6436 avatar image
0 Votes"
SQL-6436 asked SQL-6436 edited

SQL Query Help need on Train data

NA-----------

azure-data-explorer
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @SQL-6436,

Could you please provide any update? Thanks.

Best regards,
Melissa

0 Votes 0 ·
OlafHelper-2800 avatar image
0 Votes"
OlafHelper-2800 answered SQL-6436 commented

Please copy and paste into the notepad for better view.

Don't make it better, still not really readable.
Please post table design as DDL, some sample data as DML statement and the expected result.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

!149639-image.png

My Source data looks like above. Based the "NUMBEROFWAGONS" field value we get the "WAGONNUMBER" with the associated columns data name. In the above example since NUMBEROFWAGONS=1 and and "NUMBEROFAXLES"=1 the data looks above.

NUMBEROFWAGONS=1 and and "NUMBEROFAXLES"=2 the data looks below i.e. 149670-image.png
Here we are getting the 149741-image.png columns repeatedly with the same name. When loading into SQL table loading is failed because of the duplicate column (because of the same name. How can we handle the scenario?


0 Votes 0 ·
image.png (23.8 KiB)
image.png (29.6 KiB)
image.png (3.3 KiB)
MelissaMa-msft avatar image
0 Votes"
MelissaMa-msft answered SQL-6436 commented

Hi @SQL-6436,

Welcome to Microsoft Q&A!

For this type of problem we recommend that you post CREATE TABLE statements for your tables together with INSERT statements with sample data since your sample data is not readable enough.

According to your requirement, it is a little difficult to achieve in TSQL.

You could use UNPIVOT if you would like to convert one row of multiple columns to multiple rows in one table.

But there are many duplicated column names in your sample data which is not permitted in the table definition.

You may consider to deal with it in excel or other tool.

Best regards,
Melissa


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can u please help with the sample data provided

0 Votes 0 ·