Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. ProductColumn

ProductColumn

Scheduled Pinned Locked Moved Database
tutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    albCode
    wrote on last edited by
    #1

    How can I get product of two columns. example Column1 * Column2 = Result I used this to be more clearly...

    O C 3 Replies Last reply
    0
    • A albCode

      How can I get product of two columns. example Column1 * Column2 = Result I used this to be more clearly...

      O Offline
      O Offline
      oykica
      wrote on last edited by
      #2

      You need to give the column an alias. e.g. SELECT 1 * 2 AS total FROM tablename

      C 1 Reply Last reply
      0
      • O oykica

        You need to give the column an alias. e.g. SELECT 1 * 2 AS total FROM tablename

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        oykica wrote: You need to give the column an alias Actually, you don't need to give the column as an alias. It can remain without a name.


        My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

        O 1 Reply Last reply
        0
        • A albCode

          How can I get product of two columns. example Column1 * Column2 = Result I used this to be more clearly...

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          To get the product of two columns you can perform a statement like this:

          SELECT Column1 * Column2 AS Result FROM TableName

          The AS Result is optional, it just names the column "Result" and can be omitted.


          My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

          1 Reply Last reply
          0
          • A albCode

            How can I get product of two columns. example Column1 * Column2 = Result I used this to be more clearly...

            O Offline
            O Offline
            oykica
            wrote on last edited by
            #5

            Colin is correct. You don't have to provide an alias in order to get the product of the two columns. I assumed that you were trying to name your column because of the = Result in your example. If that is not what you were trying to do I hope I didn't confuse you. :)

            1 Reply Last reply
            0
            • C Colin Angus Mackay

              oykica wrote: You need to give the column an alias Actually, you don't need to give the column as an alias. It can remain without a name.


              My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

              O Offline
              O Offline
              oykica
              wrote on last edited by
              #6

              I know. I assumed he wanted to name his column because of the = Result in his example and was trying to indicate that he could achieve this by using an alias. Perhaps I read more into the example than was required. :) I think it is good practice to name your calculated columns as it makes your commands easier to read and understand.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups