title: Query in SQLite with variable and sort by Month as parameter
body: <p>I need a report with Firstname, Lastname, and TotalAmount, for all orders for a specified month. The report should be sorted so that the customer that spend the most money is on the top.</p>
  
  <p>I am able to query the list in DESC but how can the user input a variable and then create a case for ech month? My code works with the month hard-coded.</p>
  
  <p>Table Orders:</p>
  
  <pre><code>cursor.execute("DROP TABLE IF EXISTS `Orders`;")
  cursor.execute('''
  CREATE TABLE `Orders` (
    `OrderID` INTEGER PRIMARY KEY AUTOINCREMENT,
    `OrderDate` VARCHAR(11) NULL,
    `CustId` INT NULL,
    `TotalAmount` DOUBLE NULL,
    FOREIGN KEY (`CustId`) REFERENCES Customers(`CustID`) ON UPDATE CASCADE
  );
  ''')
  </code></pre>
  
  <p>Table Customers:</p>
  
  <pre><code>cursor.execute("DROP TABLE IF EXISTS `Customers`;")
  cursor.execute('''
  CREATE TABLE `Customers` (
    `CustID` INTEGER PRIMARY KEY AUTOINCREMENT,
    `FirstName` VARCHAR(11) NOT NULL,
    `LastName` VARCHAR(11) NOT NULL,
    `City` TEXT NULL,
    `Country` TEXT NULL,
    `Phone` VARCHAR(15) NULL
  );
  ''')
  </code></pre>
  
  <p>I wrote this</p>
  
  <pre><code>cursor = conn.cursor()
  for row in cursor.execute('''SELECT Firstname, Lastname, orders.TotalAmount
                              FROM customers
                              INNER JOIN orders on orders.CustID = customers.CustID
                              WHERE  orderDate like '%02-2020'
                              GROUP BY customers.custid, customers.firstname, customers.lastname
                             ORDER BY TotalAmount desc;'''):
  
                            print(row)
  cursor.close()
  </code></pre>
  
  <p>Do I have to ask the user which month they want to see the customer spent more money, store it in a variable and then do the query? or?</p>
  
  <p>Conceptually I was thinking about this:</p>
  
  <ul>
  <li>Ask for which month the report is needed</li>
  <li>Store that variable in a variable and produce a if case like:</li>
  </ul>
  
  <p><code>(if variable = 0 OR variable &gt; 12)
   then (Error that is not a month)
   elseif variable = 1 then "WHERE  orderDate like '%01-2020'"
   elseif variable = 2 then "WHERE  orderDate like '%02-2020'"
   elseif variable = 3 then "WHERE  orderDate like '%03-2020'"</code></p>
  
  <p>Not sure is the best approach.</p>