Query Sum problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

I need to sum the field *COST* in this query where data in *STATUS* is
equal to "HELD" and "OPEN", so I will have 2 totals passed below and do
not know where to begin .

All information is in 1 table.

 

Original query

select distinct(Company_name), account, City, State from table where
number = 100

 

Failed miserably 

select distinct(Company_name) , account, City, State, sum(cost) from
table where number= 100 and status="HELD" 

 

I need to be able to pull the $$ amount totals by company name for
status equal to HELD and OPEN .

 

Result 

 

 Company A      OPEN               HELD

     1233            100.00                50.00

 

Any suggestion would be appreciated.

 

Larry Sandwick

Sarreid, Ltd.

Network/System Administrator

phone: (252) 291-1414 x223

fax      : (252) 237-1592

 


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux