how to display single column in different column in sql
i am having like this - DATE NAME COUNT
-
01-03-2013 JHON 500
-
01-03-2013 JONY 2800
-
01-03-2013 ANAND 3500
-
01-03-2013 RAM 2300
-
01-03-2013 VINOD 500
-
01-04-2013 JHON 500
-
01-04-2013 JONY 2800
-
01-04-2013 ANAND 3500
-
01-04-2013 RAM 2300
-
01-04-2013 VINOD 500
i want to display like - NAME OPEING DATE OPENING COUNT CLOSING DATE CLOSING COUNT
-
JHON 01-03-2013 500 01-04-2013 500
-
JONY 01-03-2013 2800 01-04-2013 2800
-
ANAND 01-03-2013 3500 01-04-2013 3500
-
RAM 01-03-2013 2300 01-04-2013 2300
-
VINOD 01-03-2013 500 01-04-2013 500
4 2061
Is closing date always one day after the opening?
Hey maruthu, try this code... - 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
Here, tweak this code.
Happy Coding!!!
~~ CK
Hi use this qry.... - 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
-
A.DATE<=B.DATE
-
UNION ------------this union is to join same STARTDATE and ENDDATE
-
SELECT DATE,NAME,COUNT1,DATE FROM TEMPTABLE WHERE NAME IN(
-
SELECT NAME FROM
-
(SELECT COUNT(NAME) AS COUNT1,NAME FROM(
-
SELECT DISTINCT A.DATE AS STARTDATE,A.NAME,A.COUNT1,B.DATE AS ENDDATE FROM TEMPTABLE A
-
INNER JOIN TEMPTABLE B ON A.NAME=B.NAME ) AS A
-
GROUP BY NAME) AS D WHERE COUNT1=1)
Regards,
Sri Ganesh
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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"...
|
by: dehneli |
last post by:
I need to take data from listview, column by column, how cant I do that?
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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: 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,...
| |