Note that there are some explanatory texts on larger screens.

plurals
  1. POsqllite -- grouping data
    primarykey
    data
    text
    <p>I have the following query</p> <pre><code>SELECT (CASE WHEN cc.country IS NULL THEN dc.country ELSE cc.country END) AS Country,l.band FROM lotw l OUTER LEFT JOIN CountryCode cc on cc.code = l.dxcc OUTER LEFT JOIN DeleteCountry dc on dc.code = l.dxcc WHERE l.DXCC &gt; '' GROUP BY cc.Country,dc.country </code></pre> <p>Which produces the following results</p> <pre><code>Country Band Bonaire 15M St. Maarten 40M Aland Is. 20M Alaska 15M Andorra 80M Antigua &amp; Barbuda 10M Argentina 10M Aruba 10M Ascension Is. 20M Asiatic Russia 40M Austral I. 40M </code></pre> <p>………</p> <p>What I need is to get is a count of each band ? </p> <pre><code> Band Total 10M 50 20M 20 30M 5 </code></pre> <p>So I tried this:</p> <pre><code> select Band,Count(Band) FROM( SELECT (CASE WHEN cc.country IS NULL THEN dc.country ELSE cc.country END) AS Country, l.band FROM lotw l OUTER LEFT JOIN CountryCode cc on cc.code = l.dxcc OUTER LEFT JOIN DeleteCountry dc on dc.code = l.dxcc WHERE l.DXCC &gt; '' GROUP BY cc.Country,dc.country )group by Band </code></pre> <p>This almost worked but the counts are off for example 10M the count should be 79 and its comes up 27?</p> <p>however if I use this query and constrain to the 10M it works but I only get the one band :</p> <pre><code>select Band,Count(Band) FROM( SELECT (CASE WHEN cc.country IS NULL THEN dc.country ELSE cc.country END) AS Country, l.band FROM lotw l OUTER LEFT JOIN CountryCode cc on cc.code = l.dxcc OUTER LEFT JOIN DeleteCountry dc on dc.code = l.dxcc WHERE l.DXCC &gt; '' AND BAND = '10M' GROUP BY cc.Country,dc.country ) </code></pre> <p>Not sure how to go about that.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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