aggregation or what?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • davinski
    New Member
    • Mar 2007
    • 17

    aggregation or what?

    hello techies,

    Got myself a little stuck here.

    I would like to be able to have in a VIEW a column which is not defined in any table to show the total of the row from another 2 columns which are defined in the table.

    For example, if I have a table called Property with 3 columns, PropertyID, NumberOfDoubleB edrooms, NumberOfSingleB edrooms, int, int, int respectively.

    I would like in my View to return all the above columns but also an additional column called NumberOfBedroom sTotal where it would show the NumberOfDoubleB edrooms + NumberOfSingleB edrooms for each PropertyId (row).

    How would I go about doing something like this?

    Many thanks

    Davinski
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Try this

    [PHP]SELECT PropertyID, NumberOfDoubleB edrooms, NumberOfSingleB edrooms,NumberO fDoubleBedrooms + NumberOfSingleB edrooms NumberOfBedroom sTotal
    FROM Property [/PHP]

    Good Luck.

    Comment

    • davinski
      New Member
      • Mar 2007
      • 17

      #3
      Dude,

      It works!!!

      I just put an 'AS' in too like

      ...,NumberOfDou bleBedrooms + NumberOfSingleB edrooms AS NumberOfBedroom sTotal

      Thanks for your help!

      Davinski

      Originally posted by iburyak
      Try this

      [PHP]SELECT PropertyID, NumberOfDoubleB edrooms, NumberOfSingleB edrooms,NumberO fDoubleBedrooms + NumberOfSingleB edrooms NumberOfBedroom sTotal
      FROM Property [/PHP]

      Good Luck.

      Comment

      • iburyak
        Recognized Expert Top Contributor
        • Nov 2006
        • 1016

        #4
        I am not a dude.... :)

        It would work without AS.... :)


        Irina.

        Comment

        Working...