Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can try this.</p> <p>file a.awk:</p> <pre><code>BEGIN { # read list of items while ( ( getline &lt; "dummy_list" ) &gt; 0 ) { items[$1] = 0 } } { # calculate ammountof uniqur ids key = $3 SUBSEP $6 if ( ! ( key in ids ) &amp;&amp; ( $3 in items ) ) { unique_ids[$3] += 1 } # calculate ammount of duplication ids [$3,$6] += 1 # calculate range parameters range1 [$3,$6] += $5 - $4 range2 [$3,$6] += $7 } END { for ( item in items ) { print "--- item = " item " ---\n" for ( key in ids ) { split ( key, s, SUBSEP ); if ( s[1] != item ) continue; range = range2[key] * 100 / range1[key] average[item] += float ( ids[key] ) / unique_ids[item]; print "id = " s[2] "\tammount of dup = " ids[key] " range = " int ( range ) } print "\naverage = " average[item] "\n" } } </code></pre> <p>run: </p> <p><code>awk -f a.awk dummy_table</code></p> <p>output:</p> <pre><code>--- item = AAAA --- id = "ID-983" ammount of dup = 1 range = 266 id = "ID-923" ammount of dup = 2 range = 130 id = "ID-482" ammount of dup = 4 range = 110 average = 2.33333 --- item = AAAAA --- id = "ID-916" ammount of dup = 1 range = 390 average = 1 --- item = AAA --- id = "ID-999" ammount of dup = 2 range = 288 id = "ID-482" ammount of dup = 1 range = 240 id = "ID-492" ammount of dup = 2 range = 242 average = 1.66667 </code></pre> <p>There is one moment - I can't understand how you got 225 for "ID-482" and item AAA in question #3.</p> <pre><code>RANGE2 * 100 / RANGE1 = 36 * 100 / ( 58 - 43 ) = 240. </code></pre> <p>Are you sure, that your example on question #3 is correct?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload