473,383 Members | 1,885 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,383 software developers and data experts.

Combing multiple columns.

I have a table i use to store scores for employees.

EMPID Q1 Q2 Q3
1234 3 2 4

Q1,Q2 & Q3 being the separate questions and the numbers (in this case
3,2 & 4) being the actual scores for that question. I am trying to
make a query or report that will display this data combining the
separate questions columns into one column and also display the
Question name (Q1,Q2 & Q3) in its own column as shown bellow

EMPID Question Score
1234 Q1 3
1234 Q2 2
1234 Q3 4
Any help would be appreciated!

Nov 14 '07 #1
2 1446
On Nov 14, 2:14 pm, Toby Gallier <azr...@gmail.comwrote:
I have a table i use to store scores for employees.

EMPID Q1 Q2 Q3
1234 3 2 4

Q1,Q2 & Q3 being the separate questions and the numbers (in this case
3,2 & 4) being the actual scores for that question. I am trying to
make a query or report that will display this data combining the
separate questions columns into one column and also display the
Question name (Q1,Q2 & Q3) in its own column as shown bellow

EMPID Question Score
1234 Q1 3
1234 Q2 2
1234 Q3 4

Any help would be appreciated!
Yuck, It may be slow depending on how many records you are looking
at. Assuming your table name is tQuestion
SELECT EmpID, 'Q1' as Question, Q1 as Score FROM tQuestion
UNION
SELECT EmpID, 'Q2' as Question, Q2 as Score FROM tQuestion
UNION
SELECT EmpID, 'Q3' as Question, Q3 as Score FROM tQuestion

Have fun
P
Nov 15 '07 #2
suggest you normalize your tables design, then you won't have any problems
getting the result you described. two tables, as

tblEmployees
EmpID (primary key)
FirstName
LastName

tblEmployeeScores
ScoreID (primary key)
EmpID (foreign key from tblEmployees)
Question
Score

tblEmployees
EmpID FirstName Last Name
1 John Doe
2 Jane Smith

tblEmployeeScores
ScoreID EmpID Question Score
1 1 1 10
2 1 2 12
3 2 1 9
4 2 2 15
5 2 3 11

recommend you read up on relational design principles. for more information,
see http://home.att.net/~california.db/tips.html#aTip1.

hth
"Toby Gallier" <az****@gmail.comwrote in message
news:11**********************@q5g2000prf.googlegro ups.com...
I have a table i use to store scores for employees.

EMPID Q1 Q2 Q3
1234 3 2 4

Q1,Q2 & Q3 being the separate questions and the numbers (in this case
3,2 & 4) being the actual scores for that question. I am trying to
make a query or report that will display this data combining the
separate questions columns into one column and also display the
Question name (Q1,Q2 & Q3) in its own column as shown bellow

EMPID Question Score
1234 Q1 3
1234 Q2 2
1234 Q3 4
Any help would be appreciated!

Nov 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dennis | last post by:
In CSS3 it looks like we'll have multiple column flowing of text (newspaper style) in which the number of columns can be determined automatically given the available horizontal space....
7
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official...
7
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.