473,485 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

spilit one column into two columns

15 New Member
Hi,

My table
******************
edate entry
******************
01-02-2008 in
01-02-2008 in
01-02-2008 out
01-02-2008 out
01-02-2008 in
01-02-2008 in


i need count of entry column for in and out values

i need following output:
**************************

edate -------- COUNT(IN) -------- COUNT(OUT)

01-02-2008 -------- 4 ----------- 2


I tried case statement.But i didn't got exact o/p
Sep 2 '08 #1
4 2276
amitpatel66
2,367 Recognized Expert Top Contributor
Please post what you tried so far?
Sep 3 '08 #2
arulkumara
15 New Member
Hi I got following output

1 SELECT sum(CASE WHEN entry='in' THEN 1 ELSE 0 END ) as entryin,
2 sum(CASE WHEN entry='out' THEN 1 ELSE 0 END ) as entryout,edate
3 FROM app
4* GROUP BY edate
SQL> /

ENTRYIN | ENTRYOUT | EDATE
---------- | ---------- | ----------
1 | 0 | 02-09-2008
1 | 0 | 02-09-2008
1 | 0 | 02-09-2008
1 | 0 | 02-09-2008
0 | 1 | 02-09-2008
0 | 3 | 02-09-2008
0 | 1 | 02-09-2008

7 rows selected.


but i need this output:
*****************************

edate ------- ENTRYIN ------- ENTRYOUT

01-02-2008 ---------------- 4 --------------- 5
Sep 4 '08 #3
amitpatel66
2,367 Recognized Expert Top Contributor
Hi I got following output

1 SELECT sum(CASE WHEN entry='in' THEN 1 ELSE 0 END ) as entryin,
2 sum(CASE WHEN entry='out' THEN 1 ELSE 0 END ) as entryout,edate
3 FROM app
4* GROUP BY edate
SQL> /

ENTRYIN | ENTRYOUT | EDATE
---------- | ---------- | ----------
1 | 0 | 02-09-2008
1 | 0 | 02-09-2008
1 | 0 | 02-09-2008
1 | 0 | 02-09-2008
0 | 1 | 02-09-2008
0 | 3 | 02-09-2008
0 | 1 | 02-09-2008

7 rows selected.


but i need this output:
*****************************

edate ------- ENTRYIN ------- ENTRYOUT

01-02-2008 ---------------- 4 --------------- 5
Is your date column having a time stamp also?? Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT trunc(edate),sum(CASE WHEN entry='in' THEN 1 ELSE 0 END ) as entryin,
  3.   sum(CASE WHEN entry='out' THEN 1 ELSE 0 END ) as entryout,edate
  4.   FROM app
  5.  GROUP BY TRUNC(edate)
  6.  
  7.  
Sep 4 '08 #4
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Try This:

Expand|Select|Wrap|Line Numbers
  1. SELECT substr(edate, 1, 10), 
  2.     SUM(CASE WHEN edate LIKE '%in' THEN 1 ELSE 0 END) 
  3.     AS entryin, 
  4.     SUM(CASE WHEN edate LIKE '%out' THEN 1 ELSE 0 END) 
  5.     AS entryout
  6. FROM MyTable
  7. GROUP BY substr(edate, 1, 10)
  8.  
Regards
Veena
Sep 7 '08 #5

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

Similar topics

10
1651
by: GML | last post by:
I have a bound datagrid in C# based on an an SQL query. The results are displayed in a Sharepoint 2003 Webpart. I would like to add a new column based on the results of two columns in the...
6
3216
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
1
6059
by: miqbal | last post by:
How can I loop through the columns collection in client side javascript? Or how can I get a column by the key, not just by the index in the collection? in Infragistics webgrid Thanks
6
10635
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
5
11781
by: Tim | last post by:
Hi, I am trying to move a datacolumn in a datatable. What I have tried so far is to create a new datacolumn set it equal to the one I want to remove and then remove it, add another column and...
9
6085
by: Steve | last post by:
How I can remove an AutoGenerated column? I wnat to inlcude the primary key in the resultset for creating some custom LinkButtons, but I don't want it (the PK) displayed in the DataGrid. I tried...
4
10636
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
11
12843
by: surya | last post by:
hello sir, i have a table emp ,it has three fields one is empno int ,second is ename varchar(20). and last is salary , emp empno ename salary ----------- ------------...
1
3540
by: Kimmo Laine | last post by:
Hi! I need to resize the last column in my listview control so that there won´t be horizontal scrollbar. Lets first create lv and add some items: listView1.View = View.Details;
0
7090
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
7116
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
7161
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...
1
6825
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
7275
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
4551
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1376
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
247
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.