Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
raindear
Yak Posting Veteran
64 Posts |
Posted - 2014-07-01 : 13:37:37
|
HiI have a table called Store Sales with the following columnsDateTotal Qty SoldRRPTotal Value SoldBranch No.BarcodesUnit CostThen I have another table called ESales that contains thisInv DateOur Ship QtyUnit Price (RRP Inc VAT)Line TotalInvoiceOrderLineBrandPartDescriptionOur Order QtyUnit Price (Exc VAT)Discount %Discount Amt (Inc VAT)Discount Amount (Exc VAT)Tax CategoryTax ExemptGroupSales CatCust. IDTitleCustomerNameTax IDRep. IDCredit MemoUnit PriceAmountCategory IDCust. AmountNumber01ShortChar01ShortChar02ClubcardThere are matching fields but none with the same name. They areInv Date = DateOur Ship Qty = Total Qty SoldUnit Price (RRP Inc VAT) = RRPLine Total = Total Value SoldWhat I want to do in merge the values in StoreSales to ESales and create additional columns for the data that is not there, these areBranch No Barcodes Unit CostAny ideas how to insert the matching values and create the three new ones? |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-07-01 : 19:00:04
|
You'll need to clarify things before anyone can really help but first...1) "There are matching fields but none with the same name." - Who cares? There is nothing that says that the names have to be the same. If you want to join the two tables on Inv Date = Date then do it. A join condition is just a boolean expression that gets evaluated for every combination of rows and has to evaluate to True for the two rows to be joined. What that boolean expression is is up to you.In simple English, how would you answer these questions:2) How should the rows be joined? By date? Other?3) For the "missing" columns, what would you like to see appear? Branch No = "ESales"?4) How would you calculate Unit Cost? Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy |
 |
|
raindear
Yak Posting Veteran
64 Posts |
Posted - 2014-07-02 : 04:27:53
|
It's ok I resolved it. |
 |
|
|
|
|