[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-12-16
4
Medium Priority
?
800 Views
Last Modified: 2012-05-08
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
0
Comment
Question by:hershes
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Gene_Cyp
ID: 26060987
You forgot a key word such as "IN"
0
 
LVL 9

Expert Comment

by:Trideep Patel
ID: 26061229
0
 

Author Comment

by:hershes
ID: 26068365
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  
0
 
LVL 7

Accepted Solution

by:
Gene_Cyp earned 2000 total points
ID: 26070880
hershes, the error message you get signifies that there is an error in the syntax of your query.

I can point you to two urls that may give you an idea of what could be wrong:

http://msdn.microsoft.com/en-us/library/ms165579.aspx
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23825767.html


0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question