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 |
rtr1900
Starting Member
48 Posts |
Posted - 2007-11-27 : 06:54:39
|
Hi,I have a table and the layout is thisCod_articleNameamountPriceExpired dateboxDuring the process of registration of products we get a table which has repeated Articules, but different prices/expired dates/boxes. How can select them so that I get for every article a line with the sum of that article, BUT keeping in mind the filter of the price/expired datebox. I tried a lot of things using DIstinct / Sum,... but always I get it wrong. For example:Cod_Art Name Amount price Exp_date Box1234 I-Cream 5 5.5 12/12 11234 I-Cream 5 5.5 12/12 11234 I-Cream 5 5.5 12/12 21234 I-Cream 5 5.5 11/12 1Should give me as result:Cod_Art Name Amount price Exp_date Box1234 I-Cream 10 5.5 12/12 11234 I-Cream 5 5.5 12/12 21234 I-Cream 5 5.5 11/12 1is this possible? I find it difficult to filter on so many cels, as I have to check over the same table.Any help is welcome!!regards,Johny |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-27 : 07:29:03
|
Try Select Cod_article,Name,amount,Price,[Expired date],min(box) as box from tablegroup by Cod_article,Name,amount,Price,[Expired date]MadhivananFailing to plan is Planning to fail |
 |
|
rtr1900
Starting Member
48 Posts |
Posted - 2007-11-27 : 07:44:14
|
madhivanan,T H A N X !!!!!!!      You just hit the jackpot!!I added the SUM() and now I get back all the rows, summed the totalamount of that sepecial product. Just what I needed.So this is with the GROUP BY command? I will take a look at it, as it helped me a lot!Thx again for you help and fast reply!!!!Johny |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|