Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2008

    Red face Unanswered: Inner Select Column Field

    Dear all,

    I have problem in the following SQL. Please help. The problem in the inner select statement for the group by clause. Please help

    select company.billtocompany,
    (select quartername from quarter where a.orderdate between
    convert(datetime, quarter.startdate) and convert(datetime, quarter.enddate)+1) quartername,

    sum( a.qty) orderedqty

    from a, company, countrycode

    where a.billtocompany=company.compcode and
    a.countrycode=countrycode.countrycode and
    a.billtocompany='111111' and
    a.orderdate between convert(datetime, '2008/01/01') and convert(datetime, '2008/10/01')

    group by company.billtocompany, countrycode.countryname, quartername

  2. #2
    Join Date
    Jan 2007
    Provided Answers: 10
    You really have a table called "a" ?!
    Correct me if I'm wrong, but the following will return the same value for every row returned, right?
    (SELECT quartername
           FROM   quarter
           WHERE  a.orderdate BETWEEN Convert(datetime, quarter.startdate)
                                  AND Convert(datetime, quarter.enddate) +1) As [quartername]
    And I imagine you don't want that!

    I'm not going to guess at your requirements, it is up to you to provide us with full enough details to aide you to a solution.

    Please read the following link
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts