Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941

    Unanswered: SQL Statement Help

    Can anyone see what I've got wrong with this statement?
    I think I'm going blind, (or crazy):

    INSERT INTO EXCEPTIONS
    (EXC_TYPE, PRODUCT, EXC_DESC, tons_var)
    SELECT 'PROD', r,Product, 'Production for ' + r.Parent_Site + ' varies from Plan' , r.Tons-r.Mtd
    FROM (
    SELECT p.Product, p.Parent_Site, sum(p.Tons) as Tons, sum(p.MTD) as MTD
    FROM(
    SELECT #tmpManuf.PARENT_SITE,
    #tmpManuf.Product,
    #tmpManuf.TONS,
    0 AS MTD
    FROM #tmpManuf
    UNION
    SELECT #tmpProdcution.Parent_Site,
    #tmpProduction.Product,
    0 AS Tons,
    #tmpProducion.MTD
    FROM #tmpPRoduction) p
    GROUP BY p.parent_site, p.Product) r
    WHERE ABS(r.tons-r.mtd)>10

    I keep getting the error msg:
    'The select list for the INSERT statement contains more items than the insert list'
    I count 4 in both cases.

    Thanks
    Mark
    Inspiration Through Fermentation

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    INSERT INTO EXCEPTIONS

    (EXC_TYPE, PRODUCT, EXC_DESC, tons_var)-- there is 4!!!!

    SELECT 'PROD', r,Product, 'Production for ' + r.Parent_Site + ' varies -- there is 5 !!!!

    from Plan' , r.Tons-r.Mtd
    FROM (

  3. #3
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    So... SQL doesn't convert:

    'Production for ' + r.Parent_Site + ' varies from Plan'
    into one value?

    Any suggestions on what I should change?

    Thanks
    Inspiration Through Fermentation

  4. #4
    Join Date
    Sep 2003
    Posts
    522
    look at it, can you see a comma where it should be a period?

    SELECT 'PROD', r,Product

  5. #5
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Thanks! That was it.
    I'm on my way to the eye doctor...
    Inspiration Through Fermentation

Posting Permissions

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