Question
SQL (Postgres) Question: List the country and a count of Orders for all the orders that shipped outside the Germany during October 2013 in descending
SQL (Postgres) Question:
List the country and a count of Orders for all the orders that shipped outside the Germany during October 2013 in descending country sequence. (12)
My current query is:
SELECT shipcountry, COUNT(customerid) FROM orders WHERE shipcountry != 'Germany' and shippeddate BETWEEN '2013-10-01' AND '2013-10-31' GROUP BY customerid, shipcountry ORDER BY shipcountry DESC;
The output I get is:
shipcountry | count -------------+------- Venezuela | 1 USA | 1 USA | 2 USA | 2 USA | 1 USA | 1 UK | 3 Sweden | 1 Spain | 1 Portugal | 1 Portugal | 1 Mexico | 1 Mexico | 1 Ireland | 2 France | 1 France | 1 Finland | 2 Canada | 1 Belgium | 1 (19 rows)
What I need is a way to print out only one listing of the country names with the sum of the associated counts. There should be 12 rows of output. Does anyone have any suggestions?
The top of the table looks like this:
orderid | customerid | employeeid | orderdate | requireddate | shippeddate | shipvia | freight | shipname | shipaddress | shipcity | shipregion | shippostalcode | shipcountry ---------+------------+------------+---------------------+---------------------+---------------------+---------+---------+------------------------------------+------------------------------------------------+-----------------+---------------+----------------+------------- 10249 | TRADH | 6 | 2013-07-05 00:00:00 | 2013-08-16 00:00:00 | 2013-07-10 00:00:00 | 1 | 11.61 | Toms Spezialitten | Luisenstr. 48 | Mnster | | 44087 | Germany 10252 | SUPRD | 4 | 2013-07-09 00:00:00 | 2013-08-06 00:00:00 | 2013-07-11 00:00:00 | 2 | 51.30 | Suprmes dlices | Boulevard Tirou 255 | Charleroi | | B-6000 | Belgium 10250 | HANAR | 4 | 2013-07-08 00:00:00 | 2013-08-05 00:00:00 | 2013-07-12 00:00:00 | 2 | 65.83 | Hanari Carnes | Rua do Pao 67 | Rio de Janeiro | RJ | 05454-876 | Brazil 10251 | VICTE | 3 | 2013-07-08 00:00:00 | 2013-08-05 00:00:00 | 2013-07-15 00:00:00 | 1 | 41.34 | Victuailles en stock | 2 rue du Commerce | Lyon | | 69004 | France 10255 | RICSU | 9 | 2013-07-12 00:00:00 | 2013-08-09 00:00:00 | 2013-07-15 00:00:00 | 3 | 148.33 | Richter Supermarkt | Starenweg 5 | Genve | | 1204 | Switzerland 10253 | HANAR | 3 | 2013-07-10 00:00:00 | 2013-07-24 00:00:00 | 2013-07-16 00:00:00 | 2 | 58.17 | Hanari Carnes | Rua do Pao 67 | Rio de Janeiro | RJ | 05454-876 | Brazil 10248 | WILMK | 5 | 2013-07-04 00:00:00 | 2013-08-01 00:00:00 | 2013-07-16 00:00:00 | 3 | 32.38 | Vins et alcools Chevalier | 59 rue de lAbbaye | Reims | | 51100 | France 10256 | WELLI | 3 | 2013-07-15 00:00:00 | 2013-08-12 00:00:00 | 2013-07-17 00:00:00 | 2 | 13.97 | Wellington Importadora | Rua do Mercado 12 | Resende | SP | 08737-363 | Brazil 10257 | HILAA | 4 | 2013-07-16 00:00:00 | 2013-08-13 00:00:00 | 2013-07-22 00:00:00 | 3 | 81.91 | HILARIN-Abastos | Carrera 22 con Ave. Carlos Soublette #8-35 | San Cristbal | Tchira | 5022 | Venezuela 10258 | ERNSH | 1 | 2013-07-17 00:00:00 | 2013-08-14 00:00:00 | 2013-07-23 00:00:00 | 1 | 140.51 | Ernst Handel | Kirchgasse 6 | Graz | | 8010 | Austria
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started