Hiii I want to use select in select clause
this is my statement which got an error:

Select count(*) as cnt, (select count (answer_q1) from answers where  (answer_q1 = 'ضعيف'))as  a_q1
FROM            Answers

and this is the error:

Error in SELECT clause: expression near 'SELECT'.
Error in SELECT clause: expression near 'FROM'.
Missing FROM clause.
Unable to parse query text.


DO YOU ANY OTHER WAY TO WRITE THE STATEMENT AND GET SAME RESULT?????? hELP ME PLEASE

Here is an example. See if you can modify it to suit your needs:

Select Count(*) As CustCnt,
(Select Count(*) From Invoice Where Invoice.CustNumber = Customer.CustNumber) As InvCnt
From Customer
Group By Customer.CustNumber

This is same as mine still got same error

No, its not the same. Please try modifying the query again and posting your result back

still got the error even when I put the group by

Where is your modified query

Please try modifying the query again and posting your result back

You are flat horrible at copy+paste. You read my posts, think you memorize the syntax, then form the query wrong again. Please copy+paste and change table/column names.

insert into Results (cnt, a_q1) 
SELECT
(select count(*) from Answers) as cnt, 
(select count(*) from Answers where answer_q1='ضعيف')as a_q1

No this solution is not working for me.
I am getting error like "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."

ANd my query is :

INSERT INTO #ReplaceCards(s_no,card_number)

SELECT
(SELECT splitdata from splitfn('1,2,3,4,5',',')) AS s_no,
(SELECT splitdata from splitfn('6,7,8,9,10',',')) AS card_number

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.