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

  • SEARCH
  • Home
  • 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 8434351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:37:57+00:00 2026-06-10T06:37:57+00:00

I have this query, but its not working as it should, with c as

  • 0

I have this query, but its not working as it should,

with c as (select 
               month(bookingdate) as duration, 
               count(*) as totalbookings 
           from 
               entbookings
           group by month(bookingdate)
          ),
     d as (SELECT 
               duration, 
               sum(totalitems) 
           FROM 
               [DrySoftBranch].[dbo].[mnthItemWiseTotalQty] ('1') AS BkdQty
           group by duration
          )

select 
    c.duration, 
    c.totalbookings, 
    d.bkdqty 
from
    c 
    inner join d 
    on c.duration = d.duration

when I run this, I am getting

Msg 8155, Level 16, State 2, Line 1
No column was specified for column 2 of ‘d’.

Can any one tell me what am I doing wrong?

Also, when I run this,

with c as (select 
               month(bookingdate) as duration, 
               count(*) as totalbookings 
           from 
               entbookings
           group by month(bookingdate)
          ),
     d as (select 
               month(clothdeliverydate), 
               SUM(CONVERT(INT, deliveredqty)) 
           FROM 
               barcodetable
           where 
               month(clothdeliverydate) is not null
               group by month(clothdeliverydate)
          )

select 
    c.duration, 
    c.totalbookings, 
    d.bkdqty 
from
    c 
    inner join d 
    on c.duration = d.duration

I get

Msg 8155, Level 16, State 2, Line 1
No column was specified for column 1 of ‘d’.
Msg 8155, Level 16, State 2, Line 1
No column was specified for column 2 of ‘d’.

  • 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-06-10T06:37:58+00:00Added an answer on June 10, 2026 at 6:37 am

    [edit]

    I tried to rewrite your query, but even yours will work once you associate aliases to the aggregate columns in the query that defines ‘d’.


    I think you are looking for the following:

    First one:

    select 
        c.duration, 
        c.totalbookings, 
        d.bkdqty 
    from
        (select 
                   month(bookingdate) as duration, 
                   count(*) as totalbookings 
               from 
                   entbookings
               group by month(bookingdate)
        ) AS c 
        inner join 
        (SELECT 
                   duration, 
                   sum(totalitems) 'bkdqty'
               FROM 
                   [DrySoftBranch].[dbo].[mnthItemWiseTotalQty] ('1') AS BkdQty
               group by duration
        ) AS d 
        on c.duration = d.duration
    

    Second one:

    select 
        c.duration, 
        c.totalbookings, 
        d.bkdqty 
    from
        (select 
                   month(bookingdate) as duration, 
                   count(*) as totalbookings 
               from 
                   entbookings
               group by month(bookingdate)
        ) AS c 
        inner join 
        (select 
                   month(clothdeliverydate) 'clothdeliverydatemonth', 
                   SUM(CONVERT(INT, deliveredqty)) 'bkdqty'
               FROM 
                   barcodetable
               where 
                   month(clothdeliverydate) is not null
                   group by month(clothdeliverydate)
        ) AS d 
        on c.duration = d.duration
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this query but this shows column does not exist SELECT p.content, (select
I have this query working but it is not returning back exactly what I
i have this sql query select * from table where name like ? but
I have this query. It matches anything which has South in its name. But
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
I have this query... SELECT Distinct([TargetAttributeID]) FROM (SELECT distinct att1.intAttributeID as [TargetAttributeID] FROM AST_tblAttributes
Right now I have this SQL query which is valid but always times out:
I have a feeling I am completely borking this MySQL query but I'll ask
I have a problem with a query. This query works with phpMyAdmin, but I
I have query to show the table like this: but I want to PIVOT

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.