I have two columns in a table.One represents work and the other represents date on which that needs to perform..I need the output as a minimum possible combination. For the below records I am expecting the output as W1,W2,W3 on 16th and 17th . And W4,W5 on 20th. Is there anyway to achieve this in a query?
W1 15-06-2015
W1 16-06-2015
W1 17-06-2015
W2 16-06-2015
W2 17-06-2015
W2 18-06-2015
W3 16-06-2015
W3 17-06-2015
W4 20-06-2015
W4 21-06-2015
W5 20-06-2015
Then you can order by length(work_concat) if that gives you the output you're looking for. From what I can gather, you want the maximum intersection of work, correct?
However, if you want to just be given the maximum intersection and no other records, this will do that: