SQL Server를 처음 사용하고 있으며 모든 고객 정보가 포함 된보기를 만들려고합니다.SQL Server보기에서 결과가 없습니다.
Customer
은 고객이 존재하는 경우 다른 모든 테이블을 가져오고 싶은 나의 주요 테이블입니다.
SQL Server Management Studio를 사용해 보았지만 결과가 제로였습니다.
내가 다른 테이블에서 Corporation
중 분기 및 Account
밖으로 AccountNumber
과 열의 나머지 모두를 원하는 :
이 내 테이블 내가 선택했는지처럼 보일 것입니다 .
이 관리 스튜디오가 내게 준 것입니다 : 그것은 제로 결과를 반환
SELECT
Customer.Customer.*, Customer.Miscellaneous2.*, Common.Address.*,
Company.CorporationStructure.Branch AS Expr1, Customer.Delivery.*,
Customer.Miscellaneous.*, Customer.Account.AccountNumber AS Expr2
FROM
Customer.Account
INNER JOIN
Common.Address ON Customer.Account.AccountId = Common.Address.ForeignId
INNER JOIN
Company.CorporationStructure ON Customer.Account.CorporationStructureId = Company.CorporationStructure.CorporationStructureId
AND Customer.Account.CorporationStructureId = Company.CorporationStructure.CorporationStructureId
INNER JOIN
Customer.Customer ON Company.CorporationStructure.Branch = Customer.Customer.Branch
INNER JOIN
Customer.Delivery ON Company.CorporationStructure.Branch = Customer.Delivery.Branch
INNER JOIN
Customer.Miscellaneous ON Company.CorporationStructure.Branch = Customer.Miscellaneous.Branch
INNER JOIN
Customer.Miscellaneous2 ON Company.CorporationStructure.Branch = Customer.Miscellaneous2.Branch
.
누구나 내가 뭘 잘못하고 있는지 알아?
SELECT Customer.Customer.IsActive, Customer.Customer.CompanyCode, Customer.Customer.Branch, Customer.Customer.Account, Customer.Customer.TypeCompanyTank,
Customer.Customer.SalesManCode, Customer.Customer.Name, Customer.Customer.Street, Customer.Customer.City, Customer.Customer.State,
Customer.Customer.ZipCode, Customer.Customer.ZipCodeExtension, Customer.Customer.AreaCode, Customer.Customer.PhoneNumber, Customer.Customer.TaxCode,
Customer.Customer.CreditCode, Customer.Customer.Type1, Customer.Customer.FinanceChargeCode, Customer.Customer.StatementInvoiceCode,
Customer.Customer.OpenItemBalanceForward, Customer.Customer.BillingTransaction, Customer.Customer.BudgetChange, Customer.Customer.DelinquentLetter,
Customer.Customer.PriceClassA, Customer.Customer.PriceClassB, Customer.Customer.PriceClassC, Customer.Customer.PriceClassR,
Customer.Customer.InvoiceTerms, Customer.Customer.DefaultProductCode, Customer.Customer.DefaultUnitOfIssue, Customer.Customer.Type2,
Customer.Customer.BillingCycle, Customer.Customer.CurrentBalance, Customer.Customer.Over30, Customer.Customer.Over60, Customer.Customer.Over90,
Customer.Customer.Over120, Customer.Customer.PreviousStatmentBalance, Customer.Customer.DepositAmount, Customer.Customer.LastPaymenRecievedDate,
Customer.Customer.LastPaymentRecievedAmount, Customer.Customer.BudgetRate, Customer.Customer.NonBudgetBalance, Customer.Customer.BudgetBalance,
Customer.Customer.UnpaidFinanceCharges, Customer.Customer.StartDate, Customer.Customer.CreditRecord, Customer.Customer.CreditLimit,
Customer.Miscellaneous2.IsActive AS Expr3, Customer.Miscellaneous2.CompanyCode AS Expr4, Customer.Miscellaneous2.Branch AS Expr5,
Customer.Miscellaneous2.Account AS Expr6, Customer.Miscellaneous2.BillingCycleCode, Customer.Miscellaneous2.LatitudeDegree,
Customer.Miscellaneous2.LatitudeDecimal, Customer.Miscellaneous2.North, Customer.Miscellaneous2.LongitudeDegree,
Customer.Miscellaneous2.LongitudeDecimal, Customer.Miscellaneous2.West, Customer.Miscellaneous2.GEOResultCode, Customer.Miscellaneous2.DeliveryState,
Customer.Miscellaneous2.DeliveryZipCode, Customer.Miscellaneous2.DeliveryZipCodeExtension, Customer.Miscellaneous2.RouteBook,
Customer.Miscellaneous2.DriverRouteSequence, Customer.Miscellaneous2.StandingPurchaseOrderNumber, Customer.Miscellaneous2.PhoneType2,
Customer.Miscellaneous2.AreaCode2, Customer.Miscellaneous2.PhoneNumber2, Customer.Miscellaneous2.PhoneType3, Customer.Miscellaneous2.PhoneNumber3,
Customer.Miscellaneous2.EmailAddress, Customer.Miscellaneous2.ElectronicLetterOption, Customer.Miscellaneous2.ElectronicPostcardOption,
Customer.Miscellaneous2.ElectronicStatementOption, Customer.Miscellaneous2.ElectronicInvoiceOption, Customer.Miscellaneous2.LossReason,
Customer.Miscellaneous2.LossYear, Customer.Miscellaneous2.LossMonth, Customer.Miscellaneous2.GainReason, Customer.Miscellaneous2.GainYear,
Customer.Miscellaneous2.GainMonth, Customer.Miscellaneous2.LastSalesActivityDate, Customer.Miscellaneous2.ElectricTankMonitorNumber,
Common.Address.AddressId, Common.Address.ForeignId, Common.Address.AddressType, Common.Address.Street AS Expr7, Common.Address.City AS Expr8,
Common.Address.State AS Expr9, Common.Address.ZipCode AS Expr10, Common.Address.ZipCodeExtension AS Expr11, Common.Address.FromFlatFile,
Common.Address.IsUpdated, Common.Address.IsAdded, Common.Address.ClearUpdateAndAdded, Common.Address.CorporationId,
Company.CorporationStructure.Branch AS Expr1, Customer.Delivery.CompanyCode AS Expr12, Customer.Delivery.Branch AS Expr13,
Customer.Delivery.Account AS Expr14, Customer.Delivery.IsActive AS Expr15, Customer.Delivery.DegreeDayBase, Customer.Delivery.DeliveryCode,
Customer.Delivery.UseCode, Customer.Delivery.PostcardInOutFlag, Customer.Delivery.Driver, Customer.Delivery.Route, Customer.Delivery.RouteSequence,
Customer.Delivery.PreviousPercent, Customer.Delivery.PercentFull, Customer.Delivery.TankSerialNumber, Customer.Delivery.TankType, Customer.Delivery.TankUnit,
Customer.Delivery.TicketInOutFlag, Customer.Delivery.LockUseOrRateCode, Customer.Delivery.QuantityLastDelivered, Customer.Delivery.TankSize,
Customer.Delivery.NumberOfTanks, Customer.Delivery.NumberOfCompanyTanks, Customer.Delivery.GallonsPerDegreeDay, Customer.Delivery.GallonsPerDay,
Customer.Delivery.HeatingConfidence, Customer.Delivery.DailyConfidence, Customer.Delivery.LastDeliveryDate, Customer.Delivery.LastDeliveryDegreeDay,
Customer.Delivery.OptimumDeliveryDateOrDegreeDay, Customer.Delivery.RunOutDeliveryDateOrDegreeDay, Customer.Delivery.GasCheck,
Customer.Delivery.YearToDateDeliveries, Customer.Delivery.YearToDateGasDelivered, Customer.Delivery.TotalGasUsedLastYear, Customer.Delivery.AXGasUsed1,
Customer.Delivery.AXGasUsed2, Customer.Delivery.AXGasUsed3, Customer.Delivery.AXGasUsed4, Customer.Delivery.AXGasUsed5,
Customer.Delivery.AXDailyUsed1, Customer.Delivery.AXDailyUsed2, Customer.Delivery.AXDailyUsed3, Customer.Delivery.AXDailyUsed4,
Customer.Delivery.AXDailyUsed5, Customer.Delivery.AXDays1, Customer.Delivery.AXDays2, Customer.Delivery.AXDays3, Customer.Delivery.AXDays4,
Customer.Delivery.AXDays5, Customer.Miscellaneous.IsActive AS Expr16, Customer.Miscellaneous.CompanyCode AS Expr17,
Customer.Miscellaneous.Branch AS Expr18, Customer.Miscellaneous.Account AS Expr19, Customer.Miscellaneous.CareOf, Customer.Miscellaneous.DeliveryStreet,
Customer.Miscellaneous.DeliveryCity, Customer.Miscellaneous.PurchaseOrderNumber, Customer.Miscellaneous.MasterBillingBranch,
Customer.Miscellaneous.MasterBillingAccount, Customer.Account.AccountNumber AS Expr2
FROM Customer.Account LEFT OUTER JOIN
Common.Address ON Customer.Account.AccountId = Common.Address.ForeignId LEFT OUTER JOIN
Company.CorporationStructure ON Customer.Account.CorporationStructureId = Company.CorporationStructure.CorporationStructureId AND
Customer.Account.CorporationStructureId = Company.CorporationStructure.CorporationStructureId LEFT OUTER JOIN
Customer.Customer ON Company.CorporationStructure.Branch = Customer.Customer.Branch LEFT OUTER JOIN
Customer.Delivery ON Company.CorporationStructure.Branch = Customer.Delivery.Branch LEFT OUTER JOIN
Customer.Miscellaneous ON Company.CorporationStructure.Branch = Customer.Miscellaneous.Branch LEFT OUTER JOIN
Customer.Miscellaneous2 ON Company.CorporationStructure.Branch = Customer.Miscellaneous2.Branch
지금 내가 결과를 얻고 있지만 지금은 또 다시 동일한 고객을 받고 있어요 : 제안
=== 업데이트 ===은
나는 쿼리를 업데이트 :
이를 테스트하려면 한 번에 하나씩 결합하여 데이터가 떨어지는 위치를 확인하십시오. –
해당 진술에 INNER JOIN이 많이 있으며, 아마도 테이블 중 일부에 LEFT JOIN을 사용해야 할 수도 있습니다. – twoleggedhorse
제안한대로 쿼리를 업데이트했습니다. – ErocM