0
Code help for selecting in Mysql. Conditions are:
- for same 'net' and 'time' records, select the first record (min id) and another record if 'AP' is different
- for records of the same time and different net, the above condition is adopted for each group of the same net'
Example
for time 00:13:56 select records 38 and 40 (net= 11) for time 00:13:56 select records 42 and 43 (net= 80) for time 07:30:21 select records 46 and 48 (net= 11) for time 07:30:21 select record 50 (net= 30)
Table data
id net hora AP
38 11 00:13:56 4
39 11 00:13:56 4
40 11 00:13:56 1
41 11 00:13:56 4
42 80 00:13:56 5
43 80 00:13:56 2
44 80 00:13:56 5
45 80 00:13:56 5
46 11 07:30:21 4
47 11 07:30:21 4
48 11 07:30:21 3
49 11 07:30:21 4
50 30 07:30:21 1
Roberto, thank you so much! I’m still learning to use Mysql, I didn’t know that group by could be used to group multiple records at once. Your tip solved my problem!
– Frank Queiroz