i want to create table
Do you mean to create a physical table and change the structure of the table each time?!?
This sound like an awful use of the database and in this case I highly recommend you to pause all your work and go the beginning of designing your system with the help of an architect or at least a DBA with some experience with relational databases.
If you mean to get a table structure of data which is returned in a query, then please provide queries to create the table and insert some sample data + please describe the expected result SET which you want to get from the query - and we will try to help you write the query which you need :-)
In first glance, it sound to me like you will need to use Dynamic query using the built-in procedure
sp_executesql (you can read about it here) or a solution with PIVOT
Once you will provide the information I mentioned, we will be able to discuss specific solution, assuming the link to the dynamic query did not solve your needs