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
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Using avg function for new constructed column?

Using avg function for new constructed column?

Scheduled Pinned Locked Moved Database
salesquestion
3 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.
  • O Offline
    O Offline
    omegazafer
    wrote on last edited by
    #1

    Hi friends, I have a two columns as unitprice and quantity in salesreport table. I am constructing new column by multplying this two column. I gave the name of sales for this new column. I want to ge average of sales column. I tried below code but program says the column name of sales is invalid. select unitprice,quantity,unitprice*quantitiy as sales from salesreport where sales>avg(sales)

    P A 2 Replies Last reply
    0
    • O omegazafer

      Hi friends, I have a two columns as unitprice and quantity in salesreport table. I am constructing new column by multplying this two column. I gave the name of sales for this new column. I want to ge average of sales column. I tried below code but program says the column name of sales is invalid. select unitprice,quantity,unitprice*quantitiy as sales from salesreport where sales>avg(sales)

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Please don't cross post.

      "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      1 Reply Last reply
      0
      • O omegazafer

        Hi friends, I have a two columns as unitprice and quantity in salesreport table. I am constructing new column by multplying this two column. I gave the name of sales for this new column. I want to ge average of sales column. I tried below code but program says the column name of sales is invalid. select unitprice,quantity,unitprice*quantitiy as sales from salesreport where sales>avg(sales)

        A Offline
        A Offline
        andyharman
        wrote on last edited by
        #3

        select unitprice, quantity, (unitprice*quantitiy) as sales from salesreport where (unitprice*quantitiy)> (select avg(unitprice*quantitiy) from salesreport)

        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