Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

creating a new column on the fly from query

Back to Forum: Tech Off
  • User profile image
    onlinetechs​tores

    I have a sqly query that shows a column with products ordered and another column that shows product received from the products ordered, i need to do a another column that will subtract those 2 columns and put the total in a new column for each row.

     

    is this possible?

  • User profile image
    blowdart

    Sure;

    For example

    select numOrdered, numReceived from stockTable

     

    could then become

    select numOrdered, numReceived, numReceived - numOrdered as numLeft from stockTable

     

    The identifier after the AS keyword is the column name that will be used for the calculated column.

  • User profile image
    bitdisaster

    you could also add a calculated column to the table with same math that blowdart did in the query

  • User profile image
    spivonious

    One more option: you could take the query that blowdart posted and create a view from it.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.