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

how to display single column in different column in sql

how to display single column in different column in sql

i am having like this

Expand|Select|Wrap|Line Numbers
  1. DATE        NAME    COUNT
  2. 01-03-2013    JHON    500
  3. 01-03-2013    JONY    2800
  4. 01-03-2013    ANAND    3500
  5. 01-03-2013    RAM    2300
  6. 01-03-2013    VINOD    500
  7. 01-04-2013    JHON    500
  8. 01-04-2013    JONY    2800
  9. 01-04-2013    ANAND    3500
  10. 01-04-2013    RAM    2300
  11. 01-04-2013    VINOD    500
i want to display like

Expand|Select|Wrap|Line Numbers
  1. NAME    OPEING DATE    OPENING COUNT    CLOSING DATE    CLOSING COUNT
  2. JHON    01-03-2013    500            01-04-2013        500
  3. JONY    01-03-2013    2800            01-04-2013        2800
  4. ANAND    01-03-2013    3500            01-04-2013        3500
  5. RAM    01-03-2013    2300            01-04-2013        2300
  6. VINOD    01-03-2013    500            01-04-2013        500
Apr 25 '13 #1
4 2061
Rabbit
12,516 Expert Mod 8TB
Is closing date always one day after the opening?
Apr 25 '13 #2
vijay6
158 100+
Hey maruthu, try this code...

Expand|Select|Wrap|Line Numbers
  1. SELECT TOP (SELECT COUNT(DISTINCT Name) FROM Table_1) Name, D2 AS "Opening Date", N2 AS "Opening Count", D1 AS "Closing Date", N1 AS "Closing Count" FROM (SELECT T1.Name, T1.Datee AS "D1", T1.Num AS "N1", T2.Datee AS "D2", T2.Num AS "N2" FROM Table_1 T1, Table_1 T2 WHERE T1.Name = T2.Name AND T1.Datee <> T2.Datee) AS T3
Apr 29 '13 #3
ck9663
2,878 Expert 2GB
Here, tweak this code.

Happy Coding!!!


~~ CK
Apr 29 '13 #4
Hi use this qry....
Expand|Select|Wrap|Line Numbers
  1. SELECT A.DATE,A.NAME,A.COUNT1,B.DATE FROM TEMPTABLE A,TEMPTABLE B WHERE A.NAME=B.NAME AND A.DATE!=B.DATE AND 
  2. A.DATE<=B.DATE
  3. UNION ------------this union is to join same STARTDATE and ENDDATE
  4. SELECT DATE,NAME,COUNT1,DATE FROM TEMPTABLE WHERE NAME IN(
  5. SELECT NAME FROM
  6. (SELECT COUNT(NAME) AS COUNT1,NAME FROM(
  7. SELECT DISTINCT A.DATE AS STARTDATE,A.NAME,A.COUNT1,B.DATE AS ENDDATE FROM TEMPTABLE A
  8. INNER JOIN TEMPTABLE B ON A.NAME=B.NAME ) AS A
  9. GROUP BY NAME) AS D WHERE COUNT1=1)
Regards,
Sri Ganesh
Jun 25 '13 #5

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

Similar topics

11
by: csomberg | last post by:
SQL Server 2000 I will to compare a normal table with a replicated audit table having identical columns. I wish to report on the differences between the data. How can I loop though a "column...
4
by: Sharp | last post by:
I have one column with surname, the other with name. Ho to metge into a different one Surname Name? Thanks
0
by: kleinvaag | last post by:
Hi, I have the following question: Is it possible, and if so how, to sort on a different column then the one you clicked on? Example: Column 1 = PriorityID {0,1,2,3) --> this column is...
1
by: aj | last post by:
DB2 WSUE LUW v8.2 FP4 (aka v8.1 FP11) RHEL AS 4 I am EXPORTing in IXF format from one schema and then LOADing into another schema. The DB modeling tool I am using likes to put the PK columns...
8
by: nobrow | last post by:
Okay ... Im out of practice. Is it not possible to have a 2D array where each column is of a different type, say an int and a struct*? The following seg faults for me and I cant figure out what I...
0
by: ChuckB | last post by:
How would one fill a datagrid column by column? I have a function that propagates an array, as array1 runs I want to have the values fill column 1, when it completes, array2 runs and fills...
2
by: amitsaxena1981 | last post by:
hi, I am using asp.net2.0 with vb.net , I have to create gridview user control and I want to drag and drop a record to a different position in the same Gridview using AJAX .Is it possible to...
1
by: manjuns | last post by:
I have two tables Table A with columns name, eid Table B with columns text, eida select name, eid tableA where eid=1 union select name, eida tableB where eida=1
1
by: chintan85 | last post by:
Hi guys, I want to pass multiple forms to different scripts. Lets say. Can u please help me.. <form action="pass1.py" method="post" name="Submit"> <input name="gene" type="checkbox"...
0
by: dehneli | last post by:
I need to take data from listview, column by column, how cant I do that?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.