Link to home
Start Free TrialLog in
Avatar of hershes
hershes

asked on

Subquery in Query Builder (VS 2008) - Error "Error in list of function arguments: 'SELECT' not recognized.

Hi all!
I'm trying to use the subquery in this query builder and getting error
"Error in list of function arguments: 'SELECT' not recognized."
But I getting the valid results.
What I do wrong?

Thanks in advance!

This is my query:

SELECT        MAX(CDS.dest_dn) AS QDN,
(SELECT        COUNT(idcalldetail)
 FROM            calldetails AS submain
 WHERE        (status = '6') AND (submain.dest_dn = MAX(CDS.dest_dn)) AND (MAX(to_char(CDS.starttime, 'YYYY-MM-DD')) = to_char(submain.starttime,  'YYYY-MM-DD')) AND (to_char(submain.starttime, 'HH24') = MAX(to_char(CDS.starttime, 'HH24')))) AS count_answ

FROM            calldetails AS CDS, callhistory3 AS main
WHERE        ((CDS.dest_dn = '8016') AND (to_char(CDS.starttime, 'YYYY-MM-DD') = '2009-11-23')) AND (main.idcallhistory3 = CDS.idcallhistory2)
GROUP BY H1
ORDER BY H1
Avatar of Gene_Cyp
Gene_Cyp

You forgot a key word such as "IN"
Avatar of hershes

ASKER

I tried to write a very simple query with subquery..
But I have the same error(
I don't understand one thing.. Can I use subquery ("SELECT") in VS 2008 Query Builder?
Is it supported?

PS: Sorry for my english(

to Gene_Cyp:
"You forgot a key word such as "IN""
Why? This a valid SQL query (I think...)...

You can try this:
SELECT       A.id AS AID,
(SELECT        COUNT(B.id) FROM calldetails AS B ) as BID
 FROM            calldetails AS A

AID  |  BID
1     |   23
2     |   23  
ASKER CERTIFIED SOLUTION
Avatar of Gene_Cyp
Gene_Cyp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial