http://sqlfiddle.com/#!9/ea4d2/1
Here is the SQLfiddle to look at. storepkid 16 is repeated 2 times. But I want it only once. I tried DISTINCT, but it eliminated the whole repeating line so that it would not work in this case. What changes need to be made to the request in order to get the correct result? Please, help.
NOTE: I forgot to mention in the initial question that I also tried GROUP BY, but it gave incorrect data as a result of a set of records. I tried using GROUP BY in the following ways.
http://sqlfiddle.com/#!9/ea4d2/20
http://sqlfiddle.com/#!9/ea4d2/17
NOTE2: @Gabriel Valdez Timbol, I want to get the result as follows. A duplicate storepkid line should be removed.
| Storepkid | selldate | +---------------+-----------------------+ | 19 | August, 25 2015 10:00:00 | | 12 | August, 24 2015 19:00:00 | | 16 | August, 24 2015 16:00:00 | | 15 | August, 23 2015 13:00:00 | | 17 | August, 21 2015 10:00:00 |
source share