나는 다음과 같은 견해를 가지고 :뷰를 생성하고 점점 중복 거래
SELECT t.CompanyCode, t.FlatFileName, t.RecordNumber, t.Status, t.Branch, t.SalesMonthYear, t.SalesCashOrLimboCode, t.PageNumber, t.Driver, t.Truck,
t.CommonProductCode, t.CashCharge, t.SpecialFunction, t.ProductCode, t.UnitOfEntry, t.TransactionBranch, t.AccountNumber, t.ReferenceNumber, t.TransactionDate,
t.PercentFullOrWhenDueCode, t.Quantity, t.DeliveryAccountNumberForTankRentals, t.Amount, t.SalesTax, t.ProductCode2Amount, t.TankSerialNumber, t.SalesMonth,
t.TaxCode, t.SubjectToTax, t.SalesTaxRate, t.ExiseTaxRate, t.FrankHasntDecidedWhatThisFieldIs_ProbablyCentury, t.OriginalSalesMonth, t.AutoCharge,
t.ProductCode2, t.ProductCode2SpecialFunction, t.DiscountCode, t.DiscountRate, t.DiscountDays, t.Century, t.TRFRPD, t.OpenItemAmountPaid,
t.OpenItemReferenceNumber, t.InvoiceFlag, t.InvoiceNumber, t.Time, t.GasQuantity, t.AnodeReading, t.Reading, t.Reason, t.InventorySerialNumber, t.SName,
t.ErrorCode, t.MasterBillingBranchAccountNumber, t.LeaseOnFile, t.PuchaseOrderNumber, t.BillOfLaden, t.Latitude, t.Longitude, t.ContractGasPrice, t.Balance,
t.DeliveryAccount, t.BranchAccountNumber, t.LineNumber, t.DateTimeEntered, t.UserThatEntered, t.WorkstationThatEntered, t.YearMonthDayPosted,
t.HourMinutePosted, t.UserThatPosted, t.WorkstationThatPosted, t.CreditCardNumber, t.CreditCardExperationDate, t.CreditViolation, t.TransactionId, t.CorporationId,
t.IsUpdated, t.IsAdded, t.ClearUpdateAndAdded, p.Description
FROM Company.Product AS p LEFT OUTER JOIN
Company.[Transaction] AS t ON p.ProductCode = t.ProductCode AND p.CorporationId = t.CorporationId
내가 달성하기 위해 노력하고 주요 것은 제품 테이블에서 제품에 대한 설명을 얻을 상정 트랜잭션에 추가합니다. ProductCode를 기반으로해야합니다.
나는 각 트랜잭션을 한 번만 가져야하지만 각 트랜잭션의 복사본이 여러 개 있습니다. 나는 그 제품들이 각 기업에 존재한다는 것을 안다. 이 website에서
, 그것은 LEFT OUTER를 사용하여 말한다는 가입이 오른쪽 테이블에서 일치하는 행과 함께 반환에게 왼쪽 테이블의 모든 행에 가입
. 오른쪽 표에 일치하는 열 이 없으면 NULL 값을 반환합니다.
설명에 nulls이 표시되지 않으므로 잘못된 내용을 잘 모릅니다.
내가 가정을 당신은 일대 다 관계는 당신이 많은 제품이 하나의 트랜잭션에 대한 즉있다. 그렇지 않니? –
ProductCode 당 여러 CorporationID가 있습니까? 그럴 수 있습니다. 위 쿼리의 LEFT OUTER JOIN은 설명에 NULL을 제공하지 않습니다. Company 테이블의 모든 필드에 NULL을 제공합니다. 그런 일이 있습니까? SELECT 문에 DISTINCT를 추가하면 반환되는 행 수가 변경됩니까? 그렇다면 진정한 복제물을 얻었습니다. 그렇지 않으면 일부 데이터가 다릅니다. – Melanie