February 14, 2012 at 2:10 am
Desc : Maximum Quota is up to Cust and Basket, If Cust pick goods once time with amount over maximum quota, How to split Transaction? with condition need to put goods in biggest Basket of each Cust first.
Create table script
create table tblCBM(
Cust varchar(1),
Basket varchar(3),
MaxQuota int
)
GO
insert into tblCBM values ('A','aab',100)
insert into tblCBM values ('A','abb',50)
insert into tblCBM values ('B','bab',30)
insert into tblCBM values ('B','abb',30)
insert into tblCBM values ('C','cab',40)
insert into tblCBM values ('C','cbb',60)
insert into tblCBM values ('D','dab',50)
Table Structure
CustBasketMax
Aaab100
Aabb50
Bbab30
Bbbb30
Ccab40
Ccbb60
Ddab50
ExampleResuls
A pick goods 150A-aab100A-abb50
C pick goods 70C-cbb60C-cab10
February 14, 2012 at 7:50 am
This looks a lot like homework. What have you tried so far?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply