May 2, 2014 at 5:55 am
Good day
I have 3 tables , Customer , Sales Cost Charge and Sales Price
the Customer table will be joined to Sales Cost Charge
select b.[Name], b.[No_], c.[Item No_], c.[Sales Code], b.[Currency Code], c.[Item Charge Code], b.[Customer Posting Group],
b.[Salesperson Code], c.[Unit Price], c.[_ of Item Price],
c.[Starting Date], c.[Ending Date]
into Cost_Price
from [dbo].[Spier Live$Customer] b,
[dbo].[Spier Live$Sales Cost Charge] c
where b.[No_] = c.[Sales Code]
Then i select all the columns into a new table again from the new table created in my first select statement above
then i left outer join Sales price and join Sales price to the new table created on Item No
However i am not retrieving the sales cost unit price for my customers i am only getting Sales price for the customer , how can i can both sales price and sales cost for all customers.
SELECT DISTINCT [No_], [Name], d.[Currency Code], d.[Salesperson Code], d.[Item No_], a.[Item Description],
a.[Unit Price] as SalesPriceUnitPrice, a.[Starting Date] as SalesPriceStartDate, a.[Ending Date] as SalesPriceEndDate,
d.[Item Charge Code], d.[Unit Price] as CostChargeUnitPrice, d.[_ of Item Price],
d.[Starting Date] as CostChargeStartDate, d.[Ending Date] as CostChargeEndDate
INTO SalesCost_SalesPrice
FROM Cost_Price d
LEFT OUTER JOIN [dbo].[Spier Live$Sales Price] a
ON d.[Item No_] = a.[Item No_]
AND d.[Sales Code] = a.[Sales Code]
May 2, 2014 at 6:25 am
Which table contains the column which holds 'sales cost unit price'?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
May 3, 2014 at 7:04 am
The Sales Cost Charge Table it the table that holds the Sales Cost Unit Price . the original column name is Unit Price , due to there being 2 unit price columns i gave it an alias . the one unit price column which comes from the sales price table is called SalesPriceUnitPrice and the unit price in the sales cost charge table is called CostChargeUnitPrice
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply