Need Help in Sorting using partition

Database
The Teradata Database channel includes discussions around advanced Teradata features such as high-performance parallel database technology, the optimizer, mixed workload management solutions, and other related technologies.
Enthusiast

Need Help in Sorting using partition

Hi Team,

 

Need help in displaying the result set in ordered 

 

please find my input data

 

Base Table     
incident_noIncident_dateTask_DateTask_timePrimry_incident_noPrmy_inc_dt
10018/22/20189/3/20181,25010018/22/2018
10018/22/20189/3/20181,75010018/22/2018
10036/15/20189/8/201850010036/15/2018
10036/15/20189/8/201873010036/15/2018
10036/15/20189/8/20181,15510036/15/2018
10048/23/20189/11/201880010048/23/2018
10048/23/20189/11/20181,12310048/23/2018
1005 9/12/20189/14/20181,6501005 9/12/2018
1005 9/12/20189/18/20181,5011005 9/12/2018
10018/22/20189/19/20181,61210018/22/2018
10158/22/20189/19/20182,00510018/22/2018

 

Expectected restult with 4 column  in the order as below

 

Result Set   
incident_noIncident_dateTask_DateTask_time
10018/22/20189/3/20181,250
10018/22/20189/3/20181,750
10018/22/20189/19/20181,612
10158/22/20189/19/20182,005
10036/15/20189/8/2018500
10036/15/20189/8/2018730
10036/15/20189/8/20181,155
10048/23/20189/11/2018800
10048/23/20189/11/20181,123
1005 9/12/20189/14/20181,650
1005 9/12/20189/18/20181,501

 

Thanks

Vinoth.B

 

Tags (2)
5 REPLIES
Enthusiast

Re: Need Help in Sorting using partition

Hi All,

 

Any updates on above req and whether let me know is that  output result is possible or not

 

Thanks in advance

 

Thanks

Vinoth.B

 

 

 

Junior Contributor

Re: Need Help in Sorting using partition

This seems to macth your expected result:

order by Primry_incident_no, Task_Date, Task_time

 

Highlighted
Teradata Employee

Re: Need Help in Sorting using partition

Hi Vinoth,

 

Sure it's possible. It's just an ordering clause, you can order on column not shown in the select, as long as it is accessible by the query :

  select incident_no, Incident_date, Task_Date, Task_time
    from MyTable
order by Primry_incident_no, incident_no, Task_Date, Task_time

 

Enthusiast

Re: Need Help in Sorting using partition

Thanks all for the input but 

             

sorry there is small changes in records

 

Please find the input data  as below

 

Base Table     
incident_noIncident_dateTask_DateTask_timePrimry_incident_noPrmy_inc_dt
18908/22/20189/3/20181,25018908/22/2018
18908/22/20189/3/20181,75018908/22/2018
10036/15/20189/8/201850010036/15/2018
10036/15/20189/8/201873010036/15/2018
10036/15/20189/8/20181,15510036/15/2018
10048/23/20189/11/201880010048/23/2018
10048/23/20189/11/20181,12310048/23/2018
10059/12/20189/14/20181,6501005 9/12/2018
10059/12/20189/18/20181,5011005 9/12/2018
18908/22/20189/19/20181,61218908/22/2018
10158/22/20189/19/20182,0051890

8/22/2018

 

.

Expected output

Result Set   
incident_noIncident_dateTask_DateTask_time
18908/22/20189/3/20181,250
18908/22/20189/3/20181,750
18908/22/20189/19/20181,612
10158/22/20189/19/20182,005
10036/15/20189/8/2018500
10036/15/20189/8/2018730
10036/15/20189/8/20181,155
10048/23/20189/11/2018800
10048/23/20189/11/20181,123
10059/12/20189/14/20181,650
10059/12/20189/18/20181,501

 

Thanks in advance

Teradata Employee

Re: Need Help in Sorting using partition

Try this one :

  select incident_no, Incident_date, Task_Date, Task_time
    from MyTable
order by min(Task_Date) over(partition by Primry_incident_no), Primry_incident_no, Task_Date, Task_time