Hi,

I want to convert Single Column values to Row.

Table Original Content:

Code Amount Expenditure
10027 5000.00 LOCAL CONVEYANCE
10027 320.00 LOCAL CONVEYANCE
10116 1589.00 TRAVEL EXPENSES
10095 350.00 LOCAL CONVEYANCE
10095 1215.00 TRAVEL EXPENSES

Expected Output :

Code LC TE
10027 5000.00 NULL
10027 320.00 NULL
10116 NULL 1589.00
10095 350.00 1215.00


Thanks in Advance

Recommended Answers

All 2 Replies

If you had some way of grouping the rows (such as a date?) you could use a PIVOT construct. However, based on your example data, I don't see any relationship of how you could reasonably show both LC and TE. Here's what I mean...look at this scenario:

Code  Amount   Expenditure
10027 5000.00  LOCAL CONVEYANCE
10027  320.00  LOCAL CONVEYANCE
10027  100.00  TRAVEL EXPENSES  <----new example row added to your scenario
10116 1589.00  TRAVEL EXPENSES
10095  350.00  LOCAL CONVEYANCE
10095 1215.00  TRAVEL EXPENSES

Where would line 4 go? With line 2 or with line 3? The only thing I can think of is to do it programmatically rather than with straight SQL. More explanation is in order.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.