title: Creating Procedure
body: <h2>Good day / Night!</h2>
  
  <p>I am getting ready for last test which will be tomorrow. Since I have idea, what will be on test, I wanted to ask for your help on subject(Procedures). (They are my weak spot).</p>
  
  <p>Here are my tables:</p>
  
  <h2>Discount_cards</h2>
  
  <pre><code>Create table Discount_cards
  (
  Card_code Int Auto_Increment Primary key,
  Number char(9),
  Sum Decimal(10,2),
  Discount Int
  );
  </code></pre>
  
  <h1>Purchases</h1>
  
  <pre><code>Create table Purchases
  (
  SellCode Int Auto_Increment Primary key,
  Date date,
  Quantity Int,
  PricePerUnit Decimal(10,2),
  Discount Int,
  Foreign key (Discount) references Discount_cards(Card_code) On delete cascade
  );
  </code></pre>
  
  <p>So, here is my problem.</p>
  
  <p>Basically, we know how my table.Purchases looks like. (I mean colon names.)</p>
  
  <p>Now, I need to create procedure which will SELECT [Date, PricePerUnit, Quantity] where year(Date) = 2015.</p>
  
  <h1>Problem</h1>
  
  <p>It would be very easy to just select all of these columns, but that would be too easy right?</p>
  
  <p>Here is how it would look like:</p>
  
  <pre><code>delimiter //
  
  CREATE PROCEDURE procedure1 (OUT X INT)
  BEGIN
    Select 'Date', 'Quantity', 'PricePerUnit' from Purchases where year(Date) = 2015;
  END//
  delimiter ;
  CALL procedure1(@z);
  Select @z;
  </code></pre>
  
  <p>Since that's just too easy, I need to Select this same columns, but rename them, and add Total.</p>
  
  <p>Here is how it should look like:</p>
  
  <pre><code>delimiter //
  
  CREATE PROCEDURE procedure2 (OUT X INT)
  BEGIN
    Select 'Date' as Purchase_date where year(date) = 2015;    *Here is problem*
  END//
  delimiter ;
  CALL procedure2(@z);
  Select @z;
  </code></pre>
  
  <p>So yeah... here is my problem. I know how to Select date and rename it as Purchase_date, but how do I Select multiple Colons with their custom names?</p>
  
  <p>And last but not least, How to add Total in this procedure. </p>
  
  <p>Thank you for your time.</p>