473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

sorting a table by index

I have a table with answered questions that looks like that:
1 answer 1
1 answer 2
1 answer 3
1 answer 4
.
.
.
2 answer 1
2 answer 2
2 answer 3
2 answer 4
.
.
ect
and I want it to transform it to a table like this:

answers 1 answers 2 answers 3 answers 4 ...
1 | answer 1 | answer 2 | answer 3 | answer 4 | ...
2 | answer 1 | answer 2 | answer 3 | answer 4 | ...
.
.

note that I want the answers to be on different columns thus:
Expand|Select|Wrap|Line Numbers
  1. SELECT number_column
  2.    , GROUP_CONCAT( answer_column SEPARATOR ' ' ) answer_column
  3. FROM your_table
  4. GROUP BY number_column
  5. ORDER BY number_column
isn't working for me beacuse I get all the answers connected as one string in one column

thanks!!!
rotem blumberg
Aug 12 '07 #1
1 1057
pbmods
5,821 Expert 4TB
Heya, Rotem. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

The problem with the situation you're describing is that it only works if there are always 4 or less answers per question. But the whole point of storing the values the way you did is so that any question can have an unlimited number of answers.

If you need to generate a report in that format, consider loading the results in a scripting language such as PHP and formatting your report that way.
Aug 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
6
by: Ian | last post by:
Hi, can someone tell me why this join perform sort(saw it in access plan). Is there a book that explains db2 query tuning, especially this kind of stuff. SELECT C.*, O.* FROM crm.CUSTOMER C,...
11
by: rkbnair | last post by:
I have created a datagrid in my aspx with the 'AllowSorting' property to true. When clicking on the column header, the page refreshes. However the sorting is not done. Am I missing anything? I...
2
by: John Siracusa | last post by:
Are indexes useful for speeding up ORDER BY clauses? Example: CREATE TABLE t ( a INT, b INT, c INT, d INT );
6
by: carlos123 | last post by:
I have a programming assignement that i have been working on for quite some time now. I need your guys' help. My assignement is to great a table with data in it. and it will have a combobox and 2...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.