 |
|
 |
|
Next: SQLServer Error: 536, Invalid length parameter pa..
|
| Author |
Message |
External

Since: May 17, 2007 Posts: 9
|
(Msg. 1) Posted: Mon Oct 29, 2007 7:06 pm
Post subject: Table Query Archived from groups: microsoft>public>sqlserver>mseq (more info?)
|
|
|
I have a table that has the following three fields and values that I am
trying to build a query on;
Column name-FEDERAL, FICA1, FICA2
Values- 1 , 100 , 200
2 , 300 , 400
How can I get a query to look like this?;
Column- TaxCode, Value
Values- FEDERAL , 1
FEDERAL, 2
FICA1, 100
FICA1, 300
FICA2, 200
FICA2, 400
I am doing this because I am trying to build a payroll report. The other
table that I am working with is structered like this.
Thanks,
Ryan >> Stay informed about: Table Query |
|
| Back to top |
|
 |  |
External

Since: Feb 21, 2007 Posts: 457
|
(Msg. 2) Posted: Tue Oct 30, 2007 11:01 am
Post subject: Re: Table Query [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Ryan,
One easy way is:
SELECT 'FEDERAL', Federal
FROM MyTable
UNION ALL
SELECT 'FICA1', FICA1
FROM MyTable
UNION ALL
SELECT 'FICA2', FICA2
FROM MyTable
If you are on SQL Server 2005, you might also look at the UNPIVOT operator.
RLF
"Ryan Mcbee" wrote in message
>I have a table that has the following three fields and values that I am
> trying to build a query on;
>
> Column name-FEDERAL, FICA1, FICA2
> Values- 1 , 100 , 200
> 2 , 300 , 400
>
> How can I get a query to look like this?;
> Column- TaxCode, Value
> Values- FEDERAL , 1
> FEDERAL, 2
> FICA1, 100
> FICA1, 300
> FICA2, 200
> FICA2, 400
>
> I am doing this because I am trying to build a payroll report. The other
> table that I am working with is structered like this.
>
> Thanks,
> Ryan
> >> Stay informed about: Table Query |
|
| Back to top |
|
 |  |
| Related Topics: | sql query single table - I am trying to run a report. The requestor has specifics on the way it should be formatted on output. I'm going to try and explain what he's looking for as well as give the example of output which was given me. The "Central Host" is the s...
Query for only specific rows in a table? Need Help with Qu.. - We have a stored procedure that removes old data from a very large (millions of rows) table and puts it into an archive table. It grabs the top 5000 rows and moves them. B/C the database is in production and is heavily used, the job is run every 5..
query - Hi, I have some models that have hyhen in between. e.g.1200LD-VCD, abc-1234 May I know how to remove the hyhen. Thank you
query - hi i have some models that end with +SP e.g. 1234+SP, abcd+SP I want to remove only the +SP from these models. May i know how can i do it. Thank you
SQL Query - Hi all, i am not able to make up a query according to my need. can anyone help. Following is my simple query. select udf_name [Severity],st_name [Status], count(2) [count] from bugs, statuses, user_defined_attribute where udf_id =.. |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|