New answers tagged

3 votes
Accepted

Query for single return meeting multiple criteria and values

Start by joining the tables together, with the right filters on vendors in place. Looks like you need to group by subGrp and cusID to check for those Y, F, J values, then group again by subGrp to get ...
Charlieface's user avatar
  • 12.6k
0 votes

Mysql count Same Two or More Same Record as One and Summarize It

SELECT DISTINCT SUBSTRING_INDEX(global_id, '-', 1) global_id, SUM(COUNT(DISTINCT flag_status) - 1) OVER (PARTITION BY SUBSTRING_INDEX(global_id, '-', 1)) mandays FROM ...
Akina's user avatar
  • 19.7k
0 votes
Accepted

Mysql count Same Two or More Same Record as One and Summarize It

Based on your given data example the pairs could easily be found by using select GLOBAL_ID from she_cii group by GLOBAL_ID having min(FLAG_STATUS) = 'IN' and max(FLAG_STATUS) = 'OUT'; The result ...
Ergest Basha's user avatar
  • 3,925

Top 50 recent answers are included