Pregunta

I just realised that my Auto-Price Calculation doesn't fill the Prices for ListID 4. I inserted the Prices from the SELECT shown below.

For bugg research I executed the SELECT without the WHERE part and it shows me the example data row.

I can't find the error though, why it is not shown in the complete select (it has no entry with ListID = 4).

Someone can see my mistake?

Not In Error

Edit: Just tried the subselect alone, it shows no rows for the requested article. Why is the NOT IN clause unaffected by this fact? subselect

¿Fue útil?

Solución

Most likely, it's because of how you are combining the artikelnummer and the auspraegungID.

I do not think you have accounted for that fact that '100' + '0' is idential to '10' + '00'.


Instead of trying to merge two fields into one, perhaps try the following?

SELECT
  *
FROM
  #allArticles  AS allArticles
WHERE
  Artikelnummer = 'IT-810260'
  AND NOT EXISTS (SELECT *
                    FROM KHKPreisListenArtikel
                   WHERE ListeID       = 4
                     AND Artikelnummer = allArticles.Artikelnummer
                     AND Auspraegung   = allArticles.Auspraegung
                 )


If that still doesn't work, then you must have corresponding records in that other table, find them like this...

SELECT
  *
FROM
  #allArticles            AS allArticles
INNER JOIN
  KHKPreisListenArtikel   AS Preis
    ON  Preis.ListeID       = 4
    AND Preis.Artikelnummer = allArticles.Artikelnummer
    AND Preis.Auspraegung   = allArticles.Auspraegung
WHERe
  allArticles.Artikelnummer = 'IT-810260'

PLEASE ALSO NOTE

Please don't include images of code, please copy the code, so that we can copy it too.

Especially when the tables/fields are in another language...


EDIT

Here is a query that will show the cause of your original query to fail.

SELECT
  *
FROM
  #allArticles            AS allArticles
INNER JOIN
  KHKPreisListenArtikel   AS Preis
    ON  Preis.ListeID       = 4
    AND Preis.Artikelnummer       + CONVERT(VARCHAR(50), Preis.Auspraegung)
        =
        allArticles.Artikelnummer + CONVERT(VARCHAR(50), allArticles.Auspraegung)
WHERE
  allArticles.Artikelnummer = 'IT-810260'
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top