简体   繁体   中英

Compressing a table with distinct on only two columns

I have a table with no unique ID and two columns that need to be shortened and compressed down to unique values out of every third duplicate. The table looks like this. Every three records in mod_epoch and epoch_15 are the same, as I just need the distinct values. The date and epoch and travel_time_all_vehicles columns can be removed. I need the distinct travel_avg values so I can run 80th and 50th percentiles off of them per TMC.

tmc date    epoch   Travel_TIME_ALL_VEHICLES    mod_epoch   EPOCH_15    TRAVEL_avg
113N04415   1012016 184 209 64  21  200
113N04415   1012016 185 210 65  21  200
113N04415   1012016 183 181 63  21  200
113N04415   1012016 188 203 68  22  203
113N04415   1012016 186 209 66  22  203
113N04415   1012016 187 197 67  22  203
113N04415   1012016 191 205 71  23  213
113N04415   1012016 190 209 70  23  213
113N04415   1012016 189 227 69  23  213

So with this post it is hard to say what the author really needs; in general, if you want to have some distinct values from a given table you can you DISTINCT t-sql keyword.

select distinct EPOCH_15, TRAVEL_avg
from [table]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM