TCARPENTER
Programmer
Sorry if this a noob question, or has been covered, but I haven't seen quite what I'm after - or I'm asking the wrong thing.
If I structure my query like this:
I don't get the correct data for the where clause. If I structure it this way:
I get the correct data, but I don't get field names for my report writers to easily apply to their report templates - what am I doing wrong?
TIA
Todd
If I structure my query like this:
Code:
SELECT TOP 1
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'CfgDescription') AS CfgDescription,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'ConfiguredPrice') AS ConfiguredPrice,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'ImageLink') AS ImageLink,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'ArchDrop') AS ArchDrop,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'BottomPanel') AS BottomPanel,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'BottomRail') AS BottomRail,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Dims') AS Dims,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'ExteriorTreatment') AS ExteriorTreatment,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Handing') AS Handing,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Height') AS Height,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'HingeNum') AS HingeNum,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Hinges') AS Hinges,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'HingeSize') AS HingeSize,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'LockRail') AS LockRail,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'LockRailPosition') AS LockRailPosition,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Panel') AS Panel,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Profile') AS Profile,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Radius') AS Radius,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Species') AS Species,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Stain') AS Stain,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Stile') AS Stile,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Style') AS Style,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Thickness') AS Thickness,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'TopPanel') AS TopPanel,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'TopRail') AS TopRail,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'Width') AS Width,
(SELECT TOP 1
BDCComponentAttributes.Value
FROM BDCComponentAttributes
WHERE ComponentAttributeName = 'TopRailLocked') AS TopRailLocked
FROM BDCComponentAttributes INNER JOIN
BDCComponents ON BDCComponentAttributes.ComponentID = BDCComponents.ComponentID INNER JOIN
BDCConfigurations ON BDCComponents.CfgID = BDCConfigurations.CfgID
WHERE BDCConfigurations.ConfigurationID = '8492bb5c-52a1-4772-831f-dff54bf9a397'
I don't get the correct data for the where clause. If I structure it this way:
Code:
SELECT BDCComponentAttributes.ComponentAttributeName, BDCComponentAttributes.Value
FROM BDCComponentAttributes INNER JOIN
BDCComponents ON BDCComponentAttributes.ComponentID = BDCComponents.ComponentID INNER JOIN
BDCConfigurations ON BDCComponents.CfgID = BDCConfigurations.CfgID
WHERE BDCConfigurations.ConfigurationID = '8492bb5c-52a1-4772-831f-dff54bf9a397'
I get the correct data, but I don't get field names for my report writers to easily apply to their report templates - what am I doing wrong?
TIA
Todd