"No column name was specified for column..." when aliasing results of CROSS APPLY
-1
votes
1
answer
1824
views
I have this table:
from which I create this View:
This view's
Thanks!


CardId
allows me to JOIN
against the Card
table with so I can retrieve the Count
from any CardId
. Here's my SQL:
SELECT * FROM (
SELECT
si.CardId SourceCardId,
ti.CardId TargetCardId,
(SELECT TOP 1 r.Name
FROM dbo.Relationship r
WHERE r.Id = rac.RelationshipId) [Name],
Count(*) [Count]
FROM dbo.Relationship_AcquiredCard rac
JOIN dbo.AcquiredCard sac ON rac.SourceAcquiredCardId = sac.Id
JOIN dbo.AcquiredCard tac ON rac.TargetAcquiredCardId = tac.Id
JOIN dbo.CardInstance si ON sac.CardInstanceId = si.Id
JOIN dbo.CardInstance ti ON tac.CardInstanceId = ti.Id
GROUP BY si.CardId, ti.CardId, rac.RelationshipId
-- you can probably ignore everything above
) X
CROSS APPLY
(values (X.TargetCardId),
(X.SourceCardId)
) whatdoesthisdo(CardId) --wut
What does whatdoesthisdo
do? I got the CROSS APPLY
from this answer . If I try to alias in the usual way, I get this error:

Asked by DharmaTurtle
(161 rep)
Feb 16, 2020, 04:53 PM
Last activity: Feb 16, 2020, 05:16 PM
Last activity: Feb 16, 2020, 05:16 PM