473,394 Members | 2,020 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,394 software developers and data experts.

How to convert row data into columns

1
Hello Sir, when I run following query in SQL Server,

"
SELECT T0.[Dscription], t1.docdate as 'Invdate' ,STR(T1.Serial) AS 'Invoice No', T0.[Quantity], T0.[PriceBefDi],T0.LineTotal, t2.stacode,t2.taxrate,t2.taxsumsys,T0.GTotal,T4.[Location] FROM [dbo].[INV1] T0 INNER JOIN [dbo].[OINV] T1 ON T1.DocEntry = T0.DocEntry inner join inv4 t2 on (t2.docentry= t0.docentry and t2.linenum=t0.linenum) INNER JOIN OLCT T4 ON T0.LocCode = T4.Code INNER JOIN [dbo].[OITM] T3 on t0.itemcode=t3.itemcode where T1.Docdate>=[%1] and T1.Docdate<=[%2] and T0.[Dscription]=[%0]
"

I get following result

"
Item Name InvDate Invoice No Quantity unit price Rowtotal AuthCodeTaxRate
A 5/12/09 12634 15 20.75 311.25 BED @8 8
A 5/12/09 12634 15 20.75 311.25 HSC 1
A 5/12/09 12634 15 20.75 311.25 eces 2
A 5/12/09 12634 15 20.75 311.25 VAT 12.5
"
I want above result in following way

"
Item InvDate Invoice No Quty price Rowtotal BED @8 HSC eces VAT
A 5/12/09 12634 15 20.75 311.25 8 2 1 12.5
"

Please guide on this

Regards

Aarati Kollur
Dec 9 '09 #1
1 2278
nbiswas
149 100+
This kind of problems are called Cross Tab Queries and can be solved easily using PIVOTING (a feature from SQL SERVER 2005+)

Have a look

Pivot Table Data in SQL Server 2000 and 2005

Hope this helps
Dec 9 '09 #2

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

Similar topics

5
by: Cally | last post by:
Hello, I would like to convert a field from ntext field found in one database table to float field found in another database table. The reason why I want to do this is a long one. I have...
4
by: alederer | last post by:
Hallo! I need to convert the values of a varchar (..) for bit data column to a string which can be stored in a normal varchar column (with additional information). Is there a function in db2...
0
by: Thaddeus | last post by:
//Author: //Thaddeus Jacobs, MCP //Kinematic Automation, Inc. //mailto:tjacobs@kinematic.com // //Description: //convert ADO .NET dataset to ADO 2.5 2.6 2.7 recordset and v/v //DataSet to...
12
by: Brian Henry | last post by:
first question... I have a flat file which unfortinuatly has columns seperated by nulls instead of spaces (a higher up company created it this way for us) is there anyway to do a readline with this...
5
by: manmit.walia | last post by:
Hello All, I am stuck on a conversion problem. I am trying to convert my application which is written in VB.NET to C# because the project I am working on currently is being written in C#. I tried...
6
by: hazz | last post by:
ICollection CreateDataSource() { dt.Columns.Add(new DataColumn("ReportInclude", typeof(Boolean))); for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr = 0; dt.Rows.Add(dr); } void...
1
by: neeraj | last post by:
Hi All Can any give me the code for convert "DataColumn" data type of "DataTable". Even if data table already populated (have data) Actually I am creating one search module which searches the...
5
by: Artie | last post by:
Hi, I have a date field stored as an INT and need to convert to a date format mm/dd/yyyy. I'm having trouble determining what the starting date is. min(date) = 730395 max(date) = 733189 ...
12
by: Miro | last post by:
How can I convert this part of the line: Me.dgvmyData.Columns.Item("txtCellName") ' "txtCellName" which is within this line - Me.dgvmyData.Sort(Me.dgvmyData.Columns.Item("txtCellName"),...
9
by: myotheraccount | last post by:
Hello, Is there a way to convert a DataRow to a StringArray, without looping through all of the items of the DataRow? Basically, I'm trying to get the results of a query and put them into a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.