Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 17,901 of 19,505    |
|    Bob Barrows to TEKJunky    |
|    Re: An aggregate may not appear in the W    |
|    02 Sep 10 16:54:12    |
      2c2f9bf4       From: reb01501@NOyahoo.SPAMcom              TEKJunky wrote:       > I am a novice at SQL and cannot figure out an effective way to export       > a product file that only has products over 25% margin.       >       > SELECT       > p.ProductCode AS 'Mfr Part Number'       > , p.ProductName AS 'Title'       > , pd.ProductDescriptionShort AS [stripHTML-Description]       > , pe.ProductManufacturer AS 'Brand'       > , pe.UPC_code AS 'UPC'       > , pe.ProductPrice AS 'Price'       > , pe.ProductWeight AS 'Shipping Weight'       > , 'Config_FullStoreURLProductDetails.asp?ProductCode='       > + p.ProductCode + '&click=53249' AS 'Link'       > , 'Config_FullStoreURLConfig_ProductPhotosFolder/'       > + p.ProductCode + '-2.jpg' AS 'Image'       >       > FROM Products p       > INNER JOIN Products_Descriptions pd ON p.ProductID = pd.ProductID       > INNER JOIN Products_Extended pe ON pd.ProductID = pe.ProductID       >       > WHERE (p.IsChildOfProductCode is NULL OR p.IsChildOfProductCode = '')       > AND (p.HideProduct is NULL OR p.HideProduct <> 'Y')       > AND (pe.ProductPrice > 0 AND pe.ProductPrice IS NOT NULL)       > AND (SUM(pe.Vendor_Price/pe.ProductPrice) > '.25')       >       > ORDER BY p.ProductCode              I'm puzzled as to why you need the SUM. In order to SUM, you have to       GROUP BY something. But from the looks of it, you are getting individual       records so what are you intending to SUM? It would likely help if you       gave us some more details, such as what the primary keys of these tables       are. Specifically, is this query intended to return a single row per       product code? Do any of the tables in the FROM clause contain multiple       rows per product code?       It never hurts to show us a few rows of sample data followed by the       desired results from that sample data.       --       HTH,       Bob Barrows              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca