what I’m trying to do is go through a table and return semi-unique results based on a certain field. So for example with this data
field1 segment field2 field3 field4 etc
-----------------------------------------------
xxxx S1 xxx xxx xxx xxx
xxxx S4 xxx xxx xxx xxx
xxxx S1 xxx xxx xxx xxx
xxxx S2 xxx xxx xxx xxx
xxxx S2 xxx xxx xxx xxx
xxxx S1 xxx xxx xxx xxx
xxxx S3 xxx xxx xxx xxx
What I want to do is return 1 records of every segment type. The other data should come from the selected record, but which record that is doesn’t matter as long as I get 1 unique record for each segment type.
field1 segment field2 field3 field4 etc
-----------------------------------------------
xxxx S1 xxx xxx xxx xxx
xxxx S4 xxx xxx xxx xxx
xxxx S2 xxx xxx xxx xxx
xxxx S3 xxx xxx xxx xxx
Hopefully that makes sense. Also this will run against Oracle so whatever the most efficient way to do this would be great (source table will have something like 10 mil records and 30 distinct segments)
You could do something like
This will pick an arbitrary row for each
SEGMENT. When, in the future, someone decides that they do care what row is picked, you can adjust the ORDER BY in the analytic function.