Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Join two tables with matching items

$
0
0
Hi I am using Microsoft Dynamics Navision and SQL as the sourceI have two tables the main table being Value Entry that holds all the transactions being done daily and my second table being the Transfer Excise Tbl which contains the Unit Rate and litre conversion values.The Value Entry Table contains Item No's as well as the Transfer Excise Table. I need to get the exact amount item transaction if I join the two tables where there is a matching item vs Microsoft Dynamics Navision. I have tested my query against Navision and SQL give me much more transactions than Navision. for example if I test it on one item , sql gives me 941 rows and Navision for that same item gives me 460 rows. Either sql is returning duplicates or my script is wrong. I need all item transactions in the value entry table that does not exist in the Transfer Excise table[code="sql"]SELECT DISTINCT a.[Starting Date], b.[Posting Date], b.[Item No_], b.[Invoiced Quantity], a.[Litre Conversion Factor], a.[Unit Rate] , a.[Location Code], a.[Excise Location], a.[Excise Type Code], a.[Unit Of Measure Code]FROM [Transfer Excise Tbl] a , [Spier Live$Value Entry] bWHERE b.[Posting Date] > '2013-02-26 'And a.[No_] = b.[Item No_] AND b.[Location Code] = a.[Location Code]AND b.[Gen_ Bus_ Posting Group] IN ('LOCA','EXSA')AND b.[Posting Date] >= a.[Starting Date] AND b.[Invoiced Quantity] <>0AND b.[Item No_] = 'F00335'Order By b.[Posting Date][/code]

Viewing all articles
Browse latest Browse all 3145

Trending Articles