Segregate column to muti-columns based on datetime
up vote
-1
down vote
favorite
I have the following dataset
TRAN_DT; CONENT; TYPE
01/01/2018 12:00:00; AAA ; 1
01/01/2018 12:00:00; AAA ; 2
01/01/2018 12:00:00; AAA ; 3
01/01/2018 01:00:00; FFF ; 1
01/01/2018 01:00:00; FFF ; 2
I need my result to be like
01/01/2018 12:00:00;01/01/2018 01:00:00
1 AAA ;FFF
2 AAA ;FFF
3 AAA
Thank you.
sql oracle
add a comment |
up vote
-1
down vote
favorite
I have the following dataset
TRAN_DT; CONENT; TYPE
01/01/2018 12:00:00; AAA ; 1
01/01/2018 12:00:00; AAA ; 2
01/01/2018 12:00:00; AAA ; 3
01/01/2018 01:00:00; FFF ; 1
01/01/2018 01:00:00; FFF ; 2
I need my result to be like
01/01/2018 12:00:00;01/01/2018 01:00:00
1 AAA ;FFF
2 AAA ;FFF
3 AAA
Thank you.
sql oracle
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have the following dataset
TRAN_DT; CONENT; TYPE
01/01/2018 12:00:00; AAA ; 1
01/01/2018 12:00:00; AAA ; 2
01/01/2018 12:00:00; AAA ; 3
01/01/2018 01:00:00; FFF ; 1
01/01/2018 01:00:00; FFF ; 2
I need my result to be like
01/01/2018 12:00:00;01/01/2018 01:00:00
1 AAA ;FFF
2 AAA ;FFF
3 AAA
Thank you.
sql oracle
I have the following dataset
TRAN_DT; CONENT; TYPE
01/01/2018 12:00:00; AAA ; 1
01/01/2018 12:00:00; AAA ; 2
01/01/2018 12:00:00; AAA ; 3
01/01/2018 01:00:00; FFF ; 1
01/01/2018 01:00:00; FFF ; 2
I need my result to be like
01/01/2018 12:00:00;01/01/2018 01:00:00
1 AAA ;FFF
2 AAA ;FFF
3 AAA
Thank you.
sql oracle
sql oracle
edited Nov 8 at 13:34
a_horse_with_no_name
285k45428526
285k45428526
asked Nov 8 at 11:29
Nawaf
1411211
1411211
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
I think you want conditional aggregation:
select type,
max(case when tran_dt = '01/01/2018 12:00:00' then conent end) as c_20180101_12,
max(case when tran_dt = '01/01/2018 01:00:00' then conent end) as c_20180101_01
from t
group by type
order by type;
1
GROUP BY type
and no aggregation around theCASE
expression?
– MatBailie
Nov 8 at 11:56
@MatBailie . . . Thank you.
– Gordon Linoff
Nov 8 at 13:31
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I think you want conditional aggregation:
select type,
max(case when tran_dt = '01/01/2018 12:00:00' then conent end) as c_20180101_12,
max(case when tran_dt = '01/01/2018 01:00:00' then conent end) as c_20180101_01
from t
group by type
order by type;
1
GROUP BY type
and no aggregation around theCASE
expression?
– MatBailie
Nov 8 at 11:56
@MatBailie . . . Thank you.
– Gordon Linoff
Nov 8 at 13:31
add a comment |
up vote
1
down vote
I think you want conditional aggregation:
select type,
max(case when tran_dt = '01/01/2018 12:00:00' then conent end) as c_20180101_12,
max(case when tran_dt = '01/01/2018 01:00:00' then conent end) as c_20180101_01
from t
group by type
order by type;
1
GROUP BY type
and no aggregation around theCASE
expression?
– MatBailie
Nov 8 at 11:56
@MatBailie . . . Thank you.
– Gordon Linoff
Nov 8 at 13:31
add a comment |
up vote
1
down vote
up vote
1
down vote
I think you want conditional aggregation:
select type,
max(case when tran_dt = '01/01/2018 12:00:00' then conent end) as c_20180101_12,
max(case when tran_dt = '01/01/2018 01:00:00' then conent end) as c_20180101_01
from t
group by type
order by type;
I think you want conditional aggregation:
select type,
max(case when tran_dt = '01/01/2018 12:00:00' then conent end) as c_20180101_12,
max(case when tran_dt = '01/01/2018 01:00:00' then conent end) as c_20180101_01
from t
group by type
order by type;
edited Nov 8 at 13:31
answered Nov 8 at 11:39
Gordon Linoff
743k32285390
743k32285390
1
GROUP BY type
and no aggregation around theCASE
expression?
– MatBailie
Nov 8 at 11:56
@MatBailie . . . Thank you.
– Gordon Linoff
Nov 8 at 13:31
add a comment |
1
GROUP BY type
and no aggregation around theCASE
expression?
– MatBailie
Nov 8 at 11:56
@MatBailie . . . Thank you.
– Gordon Linoff
Nov 8 at 13:31
1
1
GROUP BY type
and no aggregation around the CASE
expression?– MatBailie
Nov 8 at 11:56
GROUP BY type
and no aggregation around the CASE
expression?– MatBailie
Nov 8 at 11:56
@MatBailie . . . Thank you.
– Gordon Linoff
Nov 8 at 13:31
@MatBailie . . . Thank you.
– Gordon Linoff
Nov 8 at 13:31
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206844%2fsegregate-column-to-muti-columns-based-on-datetime%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown