开发者

How can I maintain a stock report using Crystal Reports?

I want to take the following result with the help of query in Crystal Reports:

I have a stock table where three column's "type", "product", and "quantity" now I want that to drag two sql expressions in my report 1st is "INN" and 2nd is "Out" and开发者_如何学Python it comes like if the "type" is purchase so it check the "product" field and ADD the quantity and if the type is Sale it less the quantity acording to "product"

So what query should I write to get the result?


You have a table with a type field. Given your question there are some things one can only assume to answer it. So I assume:
1. type is of the type smallint
2. it is 1 for purchases or receipts and 2 for sales or deliveries
3. you mean you need to know the final stock of products
Then the query is:
select product, sum((3-2*type)*quantity) as stock from table_name group by product

if you have other values for types you will have to use different formula than 3-2*type. Good luck

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜