Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cross table update 1

Status
Not open for further replies.

johnnyasterisk

IS-IT--Management
Apr 2, 2008
26
0
0
IE
UPDATE intellicom.agent_performance ap, pbxware.ql_cache qlc
SET ap.inbcalls = count(qlc.event = 'CONNECT')
WHERE ap.agentid = qlc.type;

the above query give me the following error "Invalid use of group function". However I am not wanting to group by... I am simple wanting to select values in one table and update another. However the value i need to select in the table requires a 'COUNT' to calculate them.

Any help would be appreciated.

Thanks
 
However I am not wanting to group by...
oh yes you are wanting to group by :)

Code:
UPDATE intellicom.agent_performance AS ap
INNER
  JOIN ( SELECT type
              , SUM(CASE WHEN event = 'CONNECT'
                         THEN 1 ELSE 0 END) AS connect_count
           FROM pbxware.ql_cache 
         GROUP
             BY type ) AS qlc 
    ON qlc.type = ap.agentid
   SET ap.inbcalls = qlc.connect_count

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top