Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Having trouble

$
0
0
I have the below code and want to run a sub query but keep getting a syntax error:

Msg 156, Level 15, State 1, Line 11

Incorrect syntax near the keyword 'FROM'.

 the field [PrismProd].[Product].[tblCategory].[CategoryIdentifier} has different values depending on the hierarchy level (1 or2), I need each hierarchy level to have its own column with the value output of {CategoryIdentifier]

SELECT

[PrismProd].[Library].[tblProductDefinition].[UPC]

,[PrismProd].[Library].[tblProductVariant].[ID]as Order_Number

,[PrismProd].[Product].[tblManufacturer].[Name]as Brand

,[PrismProd].[Library].[tblProductDefinition].[Name]as Product_Name

,[PrismProd].[Library].[tblProductVariant].[PackSize]

,[PrismProd].[Planogram].[tblPlanogram].[Name]as Planogram_Name

,[PrismProd].[Groups].[tblHierarchyNode].[Name]as Category

,[PrismProd].[Product].[tblCategory].[Name]as Subcategory

,[PrismProd].[Product].[tblCategory].[CategoryIdentifier]as SubCatID

,(SELECT([PrismProd].[Product].[tblCategory].[CategoryIdentifier]FROM [PrismProd].[Product].[tblCategory]WHERE [PrismProd].[Product].[tblCategory].[HierarchyLevel]= 1)as CatID

FROM [PrismProd].[Groups].[tblHierarchyNodeBranchLink]

join [PrismProd].[Groups].[tblHierarchyNode]on [PrismProd].[Groups].[tblHierarchyNode].[NodeID]=[PrismProd].[Groups].[tblHierarchyNodeBranchLink].[NodeID]

join [PrismProd].[Planogram].[tblLifeCycle]on [PrismProd].[Planogram].[tblLifeCycle].[BranchID]=[PrismProd].[Groups].[tblHierarchyNodeBranchLink].[BranchID]

join [PrismProd].[Planogram].[tblPlanogram]on [PrismProd].[Planogram].[tblPlanogram].[PlanogramID]= [PrismProd].[Planogram].[tblLifeCycle].[PlanogramID]

join [PrismProd].[Planogram].[tblProductPosition]on [PrismProd].[Planogram].[tblProductPosition].[PlanogramID]= [PrismProd].[Planogram].[tblPlanogram].[PlanogramID]

join [PrismProd].[Library].[tblProductVariant]on  [PrismProd].[Library].[tblProductVariant].[ProdVariantID]= [PrismProd].[Planogram].[tblProductPosition].[ProdVariantID]

join [PrismProd].[Library].[tblProductDefinition]on [PrismProd].[Library].[tblProductDefinition].[ProdDefID]= [PrismProd].[Library].[tblProductVariant].[ProdDefID]

join [PrismProd].[Planogram].[tblPlanogramLocationLink]on [PrismProd].[Planogram].[tblPlanogramLocationLink].[PlanogramID]= [PrismProd].[Planogram].[tblPlanogram].[PlanogramID]

join [PrismProd].[Location].[tblLocation]on [PrismProd].[Location].[tblLocation].[LocationID]= [PrismProd].[Planogram].[tblPlanogramLocationLink].[LocationID]              

join [PrismProd].[Product].[tblCategory]on [PrismProd].[Product].[tblCategory].[CategoryID]=[PrismProd].[Library].[tblProductVariant].[CategoryID]

   

and  [PrismProd].[Product].[tblCategory].[HierarchyLevel]= [PrismProd].[Groups].[tblHierarchyNode].[HierarchyLevel]

join [PrismProd].[Product].[tblManufacturer]on [PrismProd].[Product].[tblManufacturer].[ManufacturerID]=[PrismProd].[Library].[tblProductDefinition].[ManufacturerID]

Where [PrismProd].[Groups].[tblHierarchyNode].[Name]='Mixers'

GROUPBY [PrismProd].[Library].[tblProductDefinition].[UPC],[PrismProd].[Library].[tblProductDefinition].[Name],[PrismProd].[Planogram].[tblPlanogram].[Name],[PrismProd].[Groups].[tblHierarchyNode].[Name],[PrismProd].[Library].[tblProductVariant].[PackSize],[PrismProd].[Location].[tblLocation].[LocationIdentifier],[PrismProd].[Product].[tblCategory].[Name],[PrismProd].[Product].[tblManufacturer].[Name],[PrismProd].[Library].[tblProductVariant].[ID],[PrismProd].[Product].[tblCategory].[CategoryIdentifier]

ORDERBY [PrismProd].[Library].[tblProductDefinition].[UPC]


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>