The below is my query,its getting a formation error,the query will describe the structure of it …..Could anyone help for this
SELECT (CAST(Empid AS VARCHAR)+' '+EmployeeName) AS Employee
,COUNT(ActualDate)Total_No_Days
,(SELECT COUNT(ActualDate)
from BufferListforBilling
where BufferEmpName IS NOT NULL
GROUP BY EmpId) as BillDays
,(SELECT COUNT(ActualDate)
from BufferListforBilling
where BufferEmpName IS NULL
GROUP BY EmpId) as NonBillDays
FROM BufferListforBilling
WHERE Team = 'ABC'
GROUP BY Empid ,EmployeeName
Empid ActualDate EmpName BuffEmpNames
===========================================
1 5/6/10 Roy NULL
1 6/6/10 Roy NULL
1 7/6/10 Roy Assigned
1 8/6/10 Roy Assigned
2 5/6/10 Deb Assigned
2 6/6/10 Deb NULL
2 7/6/10 Deb NULL
2 8/6/10 Deb NULL
The above is my table structure and i need to get a ouput like Below
Employee Total_No_of_Days Bill_Days Non_Bill_Days
===============================================================
1-Roy 4 2 2
2-Deb 4 1 3
You use subqueries in the select part, which is allowed only if they return scalar (single column and single row) value.
It seems that
Returns more than one row (due to group by).
It is not completely clear what your intention is. If you explain exactly what is that you want you will get better help. Also, do state your RDBMS engine.
EDIT
Taking a (hopefully not so) wild guess try this
(do notice that your
Total_No_Dayswill count only rows whereAcutalDateis NOT NULL; use COUNT(*) if you want to count all rows)