cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Remove yellow drill down arrows in query

jeroenw
Participant
0 Kudos
513

 

Hi,

I want to remove the yellow drill down arrows in this query. Especially for the field DocNum because the wrong documents open because of Union All.

Is this the right way to do that? CAST (T0.[DocNum] as nvarchar) as 'Documentnummer', 

 

 

SELECT
'Klantorder' AS 'Document',
T0.[DocDate],
T0.[CardCode],
T0.[CardName],
T0.[DocNum],
T1.[ItemCode],
T1.[Dscription],
T1.[Quantity],
T1.[TreeType]

FROM
ORDR T0
INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry]

WHERE
T0.[CardCode] =[%0] AND
T1.[Dscription] Like '%%[%1]%%' AND
T1.[TreeType] <> 'I' AND
T0.[CANCELED] = 'N'

UNION ALL

SELECT
'Uitgaande factuur en betaling' AS 'Document',
T0.[DocDate],
T0.[CardCode],
T0.[CardName],
T0.[DocNum],
T1.[ItemCode],
T1.[Dscription],
T1.[Quantity],
T1.[TreeType]

FROM
OINV T0
INNER JOIN INV1 T1 ON T0.[DocEntry] = T1.[DocEntry]

WHERE
T0.[CardCode] =[%0] AND
T1.[Dscription] Like '%%[%1]%%' AND
T1.[TreeType] <> 'I' AND
T0.[CANCELED] = 'N' AND
T0.[IsICT] = 'Y'

ORDER BY
2

 

 

 

 

 

Accepted Solutions (0)

Answers (1)

Answers (1)

LoHa
Active Contributor

Hi

you can try it like that

with DocData AS
(
SELECT
'Klantorder' AS 'Document',
T0.[DocDate],
T0.[CardCode],
T0.[CardName],
T0.[DocNum],
T1.[ItemCode],
T1.[Dscription],
T1.[Quantity],
T1.[TreeType]

FROM
ORDR T0
INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry]

WHERE
T0.[CardCode] =[%0] AND
T1.[Dscription] Like '%%[%1]%%' AND
T1.[TreeType] <> 'I' AND
T0.[CANCELED] = 'N'

UNION ALL

SELECT
'Uitgaande factuur en betaling' AS 'Document',
T0.[DocDate],
T0.[CardCode],
T0.[CardName],
T0.[DocNum],
T1.[ItemCode],
T1.[Dscription],
T1.[Quantity],
T1.[TreeType]

FROM
OINV T0
INNER JOIN INV1 T1 ON T0.[DocEntry] = T1.[DocEntry]

WHERE
T0.[CardCode] =[%0] AND
T1.[Dscription] Like '%%[%1]%%' AND
T1.[TreeType] <> 'I' AND
T0.[CANCELED] = 'N' AND
T0.[IsICT] = 'Y'
)
SELECT * FROm DocData

regards Lothar

jeroenw
Participant
0 Kudos

Thanks for your reaction. Is this also a way to do it:

CAST (T0.[DocNum] as nvarchar) as 'Documentnummer'

Is this ok?