The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> Database Management
|
combining many rows into one
Discuss combining many rows into one in the Database Management forum on Dev Shed. combining many rows into one Database Management forum discussing non-database specific SQL. Structured Query Language was designed to be a robust and standardized language for manipulating relational databases.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 2nd, 2002, 06:13 AM
|
|
Junior Member
|
|
Join Date: Apr 2002
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
combining many rows into one
Please help me figure out a solution to this problem.
I have a table in Microsoft Access that tracks the amount of money received from various companies. In some cases there is more than one amount received from the same company. Here is some sample data from the table:
CompanyID, Date, Amount, Code
5, 12/18/2000, $250.00, B M
5, 7/3/2001, $350.00, SP
8, , $100.00, M
9, , $150.00, M
9, , $250.00, gen
I need to create a new table so that all data associated with the same CompanyID appears in the same row. See example below:
CompanyID, Date, Amount, Code, Date2, Amount2, Code2
5, 12/18/2000, $250.00,B M, 7/3/2001, $350.00, SP
9, , $150.00, M, , $250.00, gen
I know this is inefficient in terms of database design. However the reason I need this new table is to export the data into excel for further manipulation.
Any ideas on how I can accomplish this task? Any help would be appreciated. Thanks. -Josh
|

April 9th, 2002, 01:50 PM
|
|
Gödelian monster
|
|
Join Date: Jul 1999
Location: Central Florida, USA
|
|
|
Sorry for the briefness of this reply, but I am short on time these days:
You want a query, not a new table. Access uses the word "query" to mean what we often call a "view" in the world of SQL.
Specifically, you want a Crosstab query, which can reorganize columns into rows. Access happens to have a wizard for creating new queries, and "Crosstab Query Wizard" is one of the choices. Play with this for awhile, and if it doesn't make sense, bring your findings back here.
Once you have created this query, then the query can be imported into Excel via ODBC (just as if it were a table), or you can even just copy and paste the ouptut into Excel.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|