Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1838092
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:26:07+00:00 2026-05-17T06:26:07+00:00

The below is my query,its getting a formation error,the query will describe the structure

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:26:07+00:00Added an answer on May 17, 2026 at 6:26 am

    You use subqueries in the select part, which is allowed only if they return scalar (single column and single row) value.

    It seems that

    SELECT COUNT(ActualDate)
    from BufferListforBilling 
    where BufferEmpName IS NOT NULL 
    GROUP BY EmpId) as BillDay
    

    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

    SELECT (CAST(Empid AS VARCHAR)+' '+EmployeeName) AS Employee
           ,COUNT(ActualDate) Total_No_Days 
           ,COUNT(BufferEmpName) as BillDays
           ,COUNT(BufferEmpName)-COUNT(ActualDate) as NonBillDays
    FROM BufferListforBilling 
    WHERE Team = 'ABC'
    GROUP BY Empid ,EmployeeName
    

    (do notice that your Total_No_Days will count only rows where AcutalDate is NOT NULL; use COUNT(*) if you want to count all rows)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Heya!, I have the below query: SELECT t1.pm_id FROM fb_user_pms AS t1, fb_user_pm_replies AS
I've tried looking up other help for this problem but I'm just not getting
Below is my query which is in Storedprocedure(SQL Server 2008) will return list of
I have the below query, which basically it retrieves the 5 top most books
I'm trying to convert the below SQL query to HQL and am having a
What would be the search condition for the query below if we wanted to
I would like to convert the below foreach statement to a LINQ query that
While mapping class i am getting error 'T' must be a non-abstract type with
I need some help in fixing the below issue. I had transaction blocks in
I am getting a set of data from the database where the query produces

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.