2024 Jun 27 10:17 AM - edited 2024 Jun 27 12:03 PM
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
Request clarification before answering.
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 DocDataregards Lothar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 14 | |
| 8 | |
| 6 | |
| 6 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.