Hey guys, iam having major problems with this query:
"average percent increase in price of work between initial sale price and last sale price"?
if any one can find a solution it would be GREATLY appreciated.
CREATE TABLE [dbo].[Sales](
[SalesID] [int] IDENTITY(1,1) NOT NULL,
[LocationID] [smallint] NOT NULL,
[VendorID] [smallint] NOT NULL,
[WorkID] [int] NOT NULL,
[Sale_Status] [char](8)
[Previous_Sale_Price] [money] NULL,
[Sale_Price] [money] NULL,
[Commission] [float] NULL,
[Date_Up_For_Sales] [datetime] NULL,
[Date_Withdrawn_From_Sale] [datetime] NULL,
[Sale_Date] [datetime] NULL,
CONSTRAINT [pk_Sales] PRIMARY KEY CLUSTERED
CREATE TABLE [dbo].[Work](
[WorkID] [int] IDENTITY(1,1) NOT NULL,
[Work_TypeID] [tinyint] NOT NULL,
[Work_Title] [varchar](40) NOT NULL,
[Creation_Date] [datetime] NOT NULL,
CONSTRAINT [pk_Work] PRIMARY KEY CLUSTEREDnot enough info, even for a homework assignment
surely the assignment gives a hint about what constitutes the initial and the final sale price? how do these relate to the columns Sale_Price and Previous_Sale_Price? what is Sale_Status and how does it apply?|||I always find it amusing that these students think an "SQL Guru" is required to help them cheat on their simple homework assignments.|||items are put up for sale, these items can be sold many times, if an item is sold or put up for sale it is marked accordingly in the sale status for eg "for sale" "sold" etc...
i need to no the average increase in price for an item between its original sale date and its last sale date.
So i assume the query will go something like this: filter by status to find all the items that have been involved in a sale, "sold" items, and then find first date it was put up for sale "Min" date_up_for_sale: then find its last sale date "max" sale_date: the average Previous_Sale_Price and Sale_Price|||Use a common table expression to find the first price for an item, a second CTE for the last price, then calculate the average over the difference of both prices. Instead of CTEs, you can use subselects. No big deal...|||if you want the average price.. then presumably you want to look at the AVERAGE of all sales, how you calculate that is up to you.. do you want a simple AVG or a weighted one.. where you give weight to number of items sold at that price
say you had 2 sales one for 10 items at 15.25, one at 14.00, one at 14.25
a simple average would be (15.25+14.00+14.25)/3= 14.50, whereas the weighted average would be (15.25*10 + 14 + 14.25)/12 =15.06
BTW have you investigated what functions are available as part of SQL?
I wonder if SQL has an AVG or even AVERAGE function that may help?|||SQL has an AVG() aggregate function (aka column function), of course.
Showing posts with label price. Show all posts
Showing posts with label price. Show all posts
Sunday, March 25, 2012
Thursday, February 16, 2012
Calculating Totals
Hi,
I have a query that shows an item that can have multiple rows of data
associated with it.
ITEM PRICE QTY_on_BO EXT PRICE PO No. QTY on PO
12345 36 3 108 2589
10
12345 36 3 108 8965
7
12345 36 3 108 4563
5
78945 20 5 100 1258
11
78945 20 5 100 9632
4
I am trying to total the QTY_on_BO column. The issue is that I only need to
sum (3+5 = 8) not (3+3+3+5+5 =19). Same thing with the column EXT_Price, I
only need to sum (108+100=208) not (108+108+108+100+100=524).
I would appreciate any help you could provide.
Thanks,
Kevin
P.S. here is my query:
SELECT va.item, i.description, v.vendor_name, va.buyer_code,
va.cost_amt, va.purchase_order, va.due_date, dbo.SKU.list_price_amt,
COALESCE
((SELECT SUM(order_qty -
original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
FROM dbo.ORDER_DETAIL AS od
WHERE (order_type IN ('E', 'P')) AND
(order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
(item_class NOT IN ('995', '998', '999'))
AND (item = va.item)),
0) AS BOQuantity, COALESCE
((SELECT SUM(order_qty -
original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
FROM dbo.ORDER_DETAIL AS od
WHERE (order_type IN ('E', 'P')) AND
(order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
(item_class NOT IN ('995', '998', '999'))
AND (item = va.item)),
0) * dbo.SKU.list_price_amt AS ext_bo_retail, va.qty AS PO_QTY
FROM dbo.VENDOR_ACTIVITY AS va INNER JOIN
dbo.ITEM AS i ON va.item = i.item INNER JOIN
dbo.VENDOR AS v ON va.vendor_key = v.vendor_key INNER
JOIN
dbo.SKU ON i.item = dbo.SKU.item CROSS JOIN
dbo.ORDER_DETAIL
WHERE (va.due_date > '2008-03-25')
GROUP BY va.item, i.description, va.buyer_code, va.cost_amt, va.due_date,
v.vendor_name, va.purchase_order, dbo.SKU.list_price_amt, va.qty
HAVING (COALESCE
((SELECT SUM(order_qty -
original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
FROM dbo.ORDER_DETAIL AS od
WHERE (order_type IN ('E', 'P')) AND
(order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
(item_class NOT IN ('995,''998', '999'))
AND (item = va.item)),
0) > 0)
ORDER BY COALESCE
((SELECT SUM(order_qty -
original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
FROM dbo.ORDER_DETAIL AS od
WHERE (order_type IN ('E', 'P')) AND
(order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
(item_class NOT IN ('995', '998', '999'))
AND (item = va.item)),
0) * dbo.SKU.list_price_amt DESC, va.due_dateI really could use some help with this.
Still trying to figure this out, but everytime I sum I get a sum of all the
contents of the cells instead of a sum of by item.
Please help if you can.
Thanks,
Kevin
"Kevin Eck" <keck@.titlenine.com> wrote in message
news:Olyzp$PkIHA.4120@.TK2MSFTNGP06.phx.gbl...
> Hi,
> I have a query that shows an item that can have multiple rows of data
> associated with it.
> ITEM PRICE QTY_on_BO EXT PRICE PO No. QTY on PO
> 12345 36 3 108
> 2589 10
> 12345 36 3 108
> 8965 7
> 12345 36 3 108
> 4563 5
> 78945 20 5 100
> 1258 11
> 78945 20 5 100
> 9632 4
> I am trying to total the QTY_on_BO column. The issue is that I only need
> to sum (3+5 = 8) not (3+3+3+5+5 =19). Same thing with the column
> EXT_Price, I only need to sum (108+100=208) not (108+108+108+100+100=524).
> I would appreciate any help you could provide.
> Thanks,
> Kevin
> P.S. here is my query:
> SELECT va.item, i.description, v.vendor_name, va.buyer_code,
> va.cost_amt, va.purchase_order, va.due_date, dbo.SKU.list_price_amt,
> COALESCE
> ((SELECT SUM(order_qty -
> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
> FROM dbo.ORDER_DETAIL AS od
> WHERE (order_type IN ('E', 'P')) AND
> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
> (item_class NOT IN ('995', '998', '999'))
> AND (item = va.item)),
> 0) AS BOQuantity, COALESCE
> ((SELECT SUM(order_qty -
> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
> FROM dbo.ORDER_DETAIL AS od
> WHERE (order_type IN ('E', 'P')) AND
> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
> (item_class NOT IN ('995', '998', '999'))
> AND (item = va.item)),
> 0) * dbo.SKU.list_price_amt AS ext_bo_retail, va.qty AS PO_QTY
> FROM dbo.VENDOR_ACTIVITY AS va INNER JOIN
> dbo.ITEM AS i ON va.item = i.item INNER JOIN
> dbo.VENDOR AS v ON va.vendor_key = v.vendor_key INNER
> JOIN
> dbo.SKU ON i.item = dbo.SKU.item CROSS JOIN
> dbo.ORDER_DETAIL
> WHERE (va.due_date > '2008-03-25')
> GROUP BY va.item, i.description, va.buyer_code, va.cost_amt, va.due_date,
> v.vendor_name, va.purchase_order, dbo.SKU.list_price_amt, va.qty
> HAVING (COALESCE
> ((SELECT SUM(order_qty -
> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
> FROM dbo.ORDER_DETAIL AS od
> WHERE (order_type IN ('E', 'P')) AND
> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
> (item_class NOT IN ('995,''998', '999'))
> AND (item = va.item)),
> 0) > 0)
> ORDER BY COALESCE
> ((SELECT SUM(order_qty -
> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
> FROM dbo.ORDER_DETAIL AS od
> WHERE (order_type IN ('E', 'P')) AND
> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
> (item_class NOT IN ('995', '998', '999'))
> AND (item = va.item)),
> 0) * dbo.SKU.list_price_amt DESC, va.due_date
>
>
>|||Hi Kevin,
I've had this problem in the past and even though I came up with a solution
it is not very elegent. My solution was, for each group (e.g. your ITEM
group), extend the SQL to include a count of the number items in the group
(e.g. join (select Item, count(*) from ... group by Item) t on ...). Then
this count value can be used to divide down the overall total to get the
correct result.
I would mind coming up with a more elegent solution that perhaps uses the
scope functions (Sum(value, scope), Count(value, scope)) but I haven't
figured that out yet.
Regards,
Brian
"Kevin Eck" <keck@.titlenine.com> wrote in message
news:%23PEwzTdkIHA.748@.TK2MSFTNGP04.phx.gbl...
>I really could use some help with this.
> Still trying to figure this out, but everytime I sum I get a sum of all
> the contents of the cells instead of a sum of by item.
> Please help if you can.
> Thanks,
> Kevin
> "Kevin Eck" <keck@.titlenine.com> wrote in message
> news:Olyzp$PkIHA.4120@.TK2MSFTNGP06.phx.gbl...
>> Hi,
>> I have a query that shows an item that can have multiple rows of data
>> associated with it.
>> ITEM PRICE QTY_on_BO EXT PRICE PO No. QTY on PO
>> 12345 36 3 108 2589 10
>> 12345 36 3 108 8965 7
>> 12345 36 3 108 4563 5
>> 78945 20 5 100 1258 11
>> 78945 20 5 100 9632 4
>> I am trying to total the QTY_on_BO column. The issue is that I only need
>> to sum (3+5 = 8) not (3+3+3+5+5 =19). Same thing with the column
>> EXT_Price, I only need to sum (108+100=208) not
>> (108+108+108+100+100=524).
>> I would appreciate any help you could provide.
>> Thanks,
>> Kevin
>> P.S. here is my query:
>> SELECT va.item, i.description, v.vendor_name, va.buyer_code,
>> va.cost_amt, va.purchase_order, va.due_date, dbo.SKU.list_price_amt,
>> COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) AS BOQuantity, COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) * dbo.SKU.list_price_amt AS ext_bo_retail, va.qty AS PO_QTY
>> FROM dbo.VENDOR_ACTIVITY AS va INNER JOIN
>> dbo.ITEM AS i ON va.item = i.item INNER JOIN
>> dbo.VENDOR AS v ON va.vendor_key = v.vendor_key
>> INNER JOIN
>> dbo.SKU ON i.item = dbo.SKU.item CROSS JOIN
>> dbo.ORDER_DETAIL
>> WHERE (va.due_date > '2008-03-25')
>> GROUP BY va.item, i.description, va.buyer_code, va.cost_amt, va.due_date,
>> v.vendor_name, va.purchase_order, dbo.SKU.list_price_amt, va.qty
>> HAVING (COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995,''998', '999'))
>> AND (item = va.item)),
>> 0) > 0)
>> ORDER BY COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) * dbo.SKU.list_price_amt DESC, va.due_date
>>
>>
>>
>|||Found a simple solution to this: divide the price or quantity by "count(*)
over(partition by item)"
"Brian" <brian1taylor@.hotmail.com> wrote in message
news:%23cJovqFoIHA.2632@.TK2MSFTNGP04.phx.gbl...
> Hi Kevin,
> I've had this problem in the past and even though I came up with a
> solution it is not very elegent. My solution was, for each group (e.g.
> your ITEM group), extend the SQL to include a count of the number items in
> the group (e.g. join (select Item, count(*) from ... group by Item) t on
> ...). Then this count value can be used to divide down the overall total
> to get the correct result.
> I would mind coming up with a more elegent solution that perhaps uses the
> scope functions (Sum(value, scope), Count(value, scope)) but I haven't
> figured that out yet.
> Regards,
> Brian
> "Kevin Eck" <keck@.titlenine.com> wrote in message
> news:%23PEwzTdkIHA.748@.TK2MSFTNGP04.phx.gbl...
>>I really could use some help with this.
>> Still trying to figure this out, but everytime I sum I get a sum of all
>> the contents of the cells instead of a sum of by item.
>> Please help if you can.
>> Thanks,
>> Kevin
>> "Kevin Eck" <keck@.titlenine.com> wrote in message
>> news:Olyzp$PkIHA.4120@.TK2MSFTNGP06.phx.gbl...
>> Hi,
>> I have a query that shows an item that can have multiple rows of data
>> associated with it.
>> ITEM PRICE QTY_on_BO EXT PRICE PO No. QTY on PO
>> 12345 36 3 108 2589 10
>> 12345 36 3 108 8965 7
>> 12345 36 3 108 4563 5
>> 78945 20 5 100 1258 11
>> 78945 20 5 100 9632 4
>> I am trying to total the QTY_on_BO column. The issue is that I only
>> need to sum (3+5 = 8) not (3+3+3+5+5 =19). Same thing with the column
>> EXT_Price, I only need to sum (108+100=208) not
>> (108+108+108+100+100=524).
>> I would appreciate any help you could provide.
>> Thanks,
>> Kevin
>> P.S. here is my query:
>> SELECT va.item, i.description, v.vendor_name, va.buyer_code,
>> va.cost_amt, va.purchase_order, va.due_date, dbo.SKU.list_price_amt,
>> COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) AS BOQuantity, COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) * dbo.SKU.list_price_amt AS ext_bo_retail, va.qty AS
>> PO_QTY
>> FROM dbo.VENDOR_ACTIVITY AS va INNER JOIN
>> dbo.ITEM AS i ON va.item = i.item INNER JOIN
>> dbo.VENDOR AS v ON va.vendor_key = v.vendor_key
>> INNER JOIN
>> dbo.SKU ON i.item = dbo.SKU.item CROSS JOIN
>> dbo.ORDER_DETAIL
>> WHERE (va.due_date > '2008-03-25')
>> GROUP BY va.item, i.description, va.buyer_code, va.cost_amt,
>> va.due_date, v.vendor_name, va.purchase_order, dbo.SKU.list_price_amt,
>> va.qty
>> HAVING (COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995,''998', '999'))
>> AND (item =>> va.item)), 0) > 0)
>> ORDER BY COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) * dbo.SKU.list_price_amt DESC, va.due_date
>>
>>
>>
>>
>
I have a query that shows an item that can have multiple rows of data
associated with it.
ITEM PRICE QTY_on_BO EXT PRICE PO No. QTY on PO
12345 36 3 108 2589
10
12345 36 3 108 8965
7
12345 36 3 108 4563
5
78945 20 5 100 1258
11
78945 20 5 100 9632
4
I am trying to total the QTY_on_BO column. The issue is that I only need to
sum (3+5 = 8) not (3+3+3+5+5 =19). Same thing with the column EXT_Price, I
only need to sum (108+100=208) not (108+108+108+100+100=524).
I would appreciate any help you could provide.
Thanks,
Kevin
P.S. here is my query:
SELECT va.item, i.description, v.vendor_name, va.buyer_code,
va.cost_amt, va.purchase_order, va.due_date, dbo.SKU.list_price_amt,
COALESCE
((SELECT SUM(order_qty -
original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
FROM dbo.ORDER_DETAIL AS od
WHERE (order_type IN ('E', 'P')) AND
(order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
(item_class NOT IN ('995', '998', '999'))
AND (item = va.item)),
0) AS BOQuantity, COALESCE
((SELECT SUM(order_qty -
original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
FROM dbo.ORDER_DETAIL AS od
WHERE (order_type IN ('E', 'P')) AND
(order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
(item_class NOT IN ('995', '998', '999'))
AND (item = va.item)),
0) * dbo.SKU.list_price_amt AS ext_bo_retail, va.qty AS PO_QTY
FROM dbo.VENDOR_ACTIVITY AS va INNER JOIN
dbo.ITEM AS i ON va.item = i.item INNER JOIN
dbo.VENDOR AS v ON va.vendor_key = v.vendor_key INNER
JOIN
dbo.SKU ON i.item = dbo.SKU.item CROSS JOIN
dbo.ORDER_DETAIL
WHERE (va.due_date > '2008-03-25')
GROUP BY va.item, i.description, va.buyer_code, va.cost_amt, va.due_date,
v.vendor_name, va.purchase_order, dbo.SKU.list_price_amt, va.qty
HAVING (COALESCE
((SELECT SUM(order_qty -
original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
FROM dbo.ORDER_DETAIL AS od
WHERE (order_type IN ('E', 'P')) AND
(order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
(item_class NOT IN ('995,''998', '999'))
AND (item = va.item)),
0) > 0)
ORDER BY COALESCE
((SELECT SUM(order_qty -
original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
FROM dbo.ORDER_DETAIL AS od
WHERE (order_type IN ('E', 'P')) AND
(order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
(item_class NOT IN ('995', '998', '999'))
AND (item = va.item)),
0) * dbo.SKU.list_price_amt DESC, va.due_dateI really could use some help with this.
Still trying to figure this out, but everytime I sum I get a sum of all the
contents of the cells instead of a sum of by item.
Please help if you can.
Thanks,
Kevin
"Kevin Eck" <keck@.titlenine.com> wrote in message
news:Olyzp$PkIHA.4120@.TK2MSFTNGP06.phx.gbl...
> Hi,
> I have a query that shows an item that can have multiple rows of data
> associated with it.
> ITEM PRICE QTY_on_BO EXT PRICE PO No. QTY on PO
> 12345 36 3 108
> 2589 10
> 12345 36 3 108
> 8965 7
> 12345 36 3 108
> 4563 5
> 78945 20 5 100
> 1258 11
> 78945 20 5 100
> 9632 4
> I am trying to total the QTY_on_BO column. The issue is that I only need
> to sum (3+5 = 8) not (3+3+3+5+5 =19). Same thing with the column
> EXT_Price, I only need to sum (108+100=208) not (108+108+108+100+100=524).
> I would appreciate any help you could provide.
> Thanks,
> Kevin
> P.S. here is my query:
> SELECT va.item, i.description, v.vendor_name, va.buyer_code,
> va.cost_amt, va.purchase_order, va.due_date, dbo.SKU.list_price_amt,
> COALESCE
> ((SELECT SUM(order_qty -
> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
> FROM dbo.ORDER_DETAIL AS od
> WHERE (order_type IN ('E', 'P')) AND
> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
> (item_class NOT IN ('995', '998', '999'))
> AND (item = va.item)),
> 0) AS BOQuantity, COALESCE
> ((SELECT SUM(order_qty -
> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
> FROM dbo.ORDER_DETAIL AS od
> WHERE (order_type IN ('E', 'P')) AND
> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
> (item_class NOT IN ('995', '998', '999'))
> AND (item = va.item)),
> 0) * dbo.SKU.list_price_amt AS ext_bo_retail, va.qty AS PO_QTY
> FROM dbo.VENDOR_ACTIVITY AS va INNER JOIN
> dbo.ITEM AS i ON va.item = i.item INNER JOIN
> dbo.VENDOR AS v ON va.vendor_key = v.vendor_key INNER
> JOIN
> dbo.SKU ON i.item = dbo.SKU.item CROSS JOIN
> dbo.ORDER_DETAIL
> WHERE (va.due_date > '2008-03-25')
> GROUP BY va.item, i.description, va.buyer_code, va.cost_amt, va.due_date,
> v.vendor_name, va.purchase_order, dbo.SKU.list_price_amt, va.qty
> HAVING (COALESCE
> ((SELECT SUM(order_qty -
> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
> FROM dbo.ORDER_DETAIL AS od
> WHERE (order_type IN ('E', 'P')) AND
> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
> (item_class NOT IN ('995,''998', '999'))
> AND (item = va.item)),
> 0) > 0)
> ORDER BY COALESCE
> ((SELECT SUM(order_qty -
> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
> FROM dbo.ORDER_DETAIL AS od
> WHERE (order_type IN ('E', 'P')) AND
> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
> (item_class NOT IN ('995', '998', '999'))
> AND (item = va.item)),
> 0) * dbo.SKU.list_price_amt DESC, va.due_date
>
>
>|||Hi Kevin,
I've had this problem in the past and even though I came up with a solution
it is not very elegent. My solution was, for each group (e.g. your ITEM
group), extend the SQL to include a count of the number items in the group
(e.g. join (select Item, count(*) from ... group by Item) t on ...). Then
this count value can be used to divide down the overall total to get the
correct result.
I would mind coming up with a more elegent solution that perhaps uses the
scope functions (Sum(value, scope), Count(value, scope)) but I haven't
figured that out yet.
Regards,
Brian
"Kevin Eck" <keck@.titlenine.com> wrote in message
news:%23PEwzTdkIHA.748@.TK2MSFTNGP04.phx.gbl...
>I really could use some help with this.
> Still trying to figure this out, but everytime I sum I get a sum of all
> the contents of the cells instead of a sum of by item.
> Please help if you can.
> Thanks,
> Kevin
> "Kevin Eck" <keck@.titlenine.com> wrote in message
> news:Olyzp$PkIHA.4120@.TK2MSFTNGP06.phx.gbl...
>> Hi,
>> I have a query that shows an item that can have multiple rows of data
>> associated with it.
>> ITEM PRICE QTY_on_BO EXT PRICE PO No. QTY on PO
>> 12345 36 3 108 2589 10
>> 12345 36 3 108 8965 7
>> 12345 36 3 108 4563 5
>> 78945 20 5 100 1258 11
>> 78945 20 5 100 9632 4
>> I am trying to total the QTY_on_BO column. The issue is that I only need
>> to sum (3+5 = 8) not (3+3+3+5+5 =19). Same thing with the column
>> EXT_Price, I only need to sum (108+100=208) not
>> (108+108+108+100+100=524).
>> I would appreciate any help you could provide.
>> Thanks,
>> Kevin
>> P.S. here is my query:
>> SELECT va.item, i.description, v.vendor_name, va.buyer_code,
>> va.cost_amt, va.purchase_order, va.due_date, dbo.SKU.list_price_amt,
>> COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) AS BOQuantity, COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) * dbo.SKU.list_price_amt AS ext_bo_retail, va.qty AS PO_QTY
>> FROM dbo.VENDOR_ACTIVITY AS va INNER JOIN
>> dbo.ITEM AS i ON va.item = i.item INNER JOIN
>> dbo.VENDOR AS v ON va.vendor_key = v.vendor_key
>> INNER JOIN
>> dbo.SKU ON i.item = dbo.SKU.item CROSS JOIN
>> dbo.ORDER_DETAIL
>> WHERE (va.due_date > '2008-03-25')
>> GROUP BY va.item, i.description, va.buyer_code, va.cost_amt, va.due_date,
>> v.vendor_name, va.purchase_order, dbo.SKU.list_price_amt, va.qty
>> HAVING (COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995,''998', '999'))
>> AND (item = va.item)),
>> 0) > 0)
>> ORDER BY COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) * dbo.SKU.list_price_amt DESC, va.due_date
>>
>>
>>
>|||Found a simple solution to this: divide the price or quantity by "count(*)
over(partition by item)"
"Brian" <brian1taylor@.hotmail.com> wrote in message
news:%23cJovqFoIHA.2632@.TK2MSFTNGP04.phx.gbl...
> Hi Kevin,
> I've had this problem in the past and even though I came up with a
> solution it is not very elegent. My solution was, for each group (e.g.
> your ITEM group), extend the SQL to include a count of the number items in
> the group (e.g. join (select Item, count(*) from ... group by Item) t on
> ...). Then this count value can be used to divide down the overall total
> to get the correct result.
> I would mind coming up with a more elegent solution that perhaps uses the
> scope functions (Sum(value, scope), Count(value, scope)) but I haven't
> figured that out yet.
> Regards,
> Brian
> "Kevin Eck" <keck@.titlenine.com> wrote in message
> news:%23PEwzTdkIHA.748@.TK2MSFTNGP04.phx.gbl...
>>I really could use some help with this.
>> Still trying to figure this out, but everytime I sum I get a sum of all
>> the contents of the cells instead of a sum of by item.
>> Please help if you can.
>> Thanks,
>> Kevin
>> "Kevin Eck" <keck@.titlenine.com> wrote in message
>> news:Olyzp$PkIHA.4120@.TK2MSFTNGP06.phx.gbl...
>> Hi,
>> I have a query that shows an item that can have multiple rows of data
>> associated with it.
>> ITEM PRICE QTY_on_BO EXT PRICE PO No. QTY on PO
>> 12345 36 3 108 2589 10
>> 12345 36 3 108 8965 7
>> 12345 36 3 108 4563 5
>> 78945 20 5 100 1258 11
>> 78945 20 5 100 9632 4
>> I am trying to total the QTY_on_BO column. The issue is that I only
>> need to sum (3+5 = 8) not (3+3+3+5+5 =19). Same thing with the column
>> EXT_Price, I only need to sum (108+100=208) not
>> (108+108+108+100+100=524).
>> I would appreciate any help you could provide.
>> Thanks,
>> Kevin
>> P.S. here is my query:
>> SELECT va.item, i.description, v.vendor_name, va.buyer_code,
>> va.cost_amt, va.purchase_order, va.due_date, dbo.SKU.list_price_amt,
>> COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) AS BOQuantity, COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) * dbo.SKU.list_price_amt AS ext_bo_retail, va.qty AS
>> PO_QTY
>> FROM dbo.VENDOR_ACTIVITY AS va INNER JOIN
>> dbo.ITEM AS i ON va.item = i.item INNER JOIN
>> dbo.VENDOR AS v ON va.vendor_key = v.vendor_key
>> INNER JOIN
>> dbo.SKU ON i.item = dbo.SKU.item CROSS JOIN
>> dbo.ORDER_DETAIL
>> WHERE (va.due_date > '2008-03-25')
>> GROUP BY va.item, i.description, va.buyer_code, va.cost_amt,
>> va.due_date, v.vendor_name, va.purchase_order, dbo.SKU.list_price_amt,
>> va.qty
>> HAVING (COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995,''998', '999'))
>> AND (item =>> va.item)), 0) > 0)
>> ORDER BY COALESCE
>> ((SELECT SUM(order_qty -
>> original_reserve_qty - cancel_qty - shipped_qty) AS Expr1
>> FROM dbo.ORDER_DETAIL AS od
>> WHERE (order_type IN ('E', 'P')) AND
>> (order_qty - original_reserve_qty - cancel_qty - shipped_qty > 0) AND
>> (item_class NOT IN ('995', '998', '999'))
>> AND (item =>> va.item)), 0) * dbo.SKU.list_price_amt DESC, va.due_date
>>
>>
>>
>>
>
Tuesday, February 14, 2012
Calculating leaf pages
I am trying to understand an example of indexing I read about.
Given the following SQL statement:
select title
from titles
where price between $20.00 and $30.00
The size of the table in rows and pages, the number of rows per page, and the
number of rows that the query returns:
1,000,000 rows (books)
190,000 are priced between $20 and $30
10 rows per page; pages 75 percent full; approximately 140,000 pages
There is a statement that I read which said:
Based upon a nonclustered index on price, title (and the table does not have
a clustered index) the query can perform a matching index scan, finding the
first page with a price of $20 via index pointers, and then scanning forward
on the leaf level until it finds a price more than $30. This index requires
about 35,700 leaf pages, so to scan the matching leaf pages requires about 6,
800 reads.
The part I do not understand is "This index requires about 35,700 leaf pages.
" I have a basic understanding of the leaf structure of a nonclustered index,
but I do not understand the value 35,700. How was 35,700 determined or
calculated based off the given data?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200606/1> The part I do not understand is "This index requires about 35,700 leaf
> pages.
> " I have a basic understanding of the leaf structure of a nonclustered
> index,
> but I do not understand the value 35,700. How was 35,700 determined or
> calculated based off the given data?
The number of leaf nodes in the non-clustered index cannot be calculated
from the data given. Storage requirements depend on the data types of the
key columns and, for variable length data, the average value length. It
seems the average title is about 50 characters, assuming a varchar data type
and smallmoney for price.
It appears to me the point of this indexing example is to demonstrate the
relative efficiency of a covering non-clustered index rather than how to
calculate space index requirements.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"cbrichards" <u3288@.uwe> wrote in message news:612e0f3c23791@.uwe...
>I am trying to understand an example of indexing I read about.
> Given the following SQL statement:
> select title
> from titles
> where price between $20.00 and $30.00
> The size of the table in rows and pages, the number of rows per page, and
> the
> number of rows that the query returns:
> 1,000,000 rows (books)
> 190,000 are priced between $20 and $30
> 10 rows per page; pages 75 percent full; approximately 140,000 pages
> There is a statement that I read which said:
> Based upon a nonclustered index on price, title (and the table does not
> have
> a clustered index) the query can perform a matching index scan, finding
> the
> first page with a price of $20 via index pointers, and then scanning
> forward
> on the leaf level until it finds a price more than $30. This index
> requires
> about 35,700 leaf pages, so to scan the matching leaf pages requires about
> 6,
> 800 reads.
> The part I do not understand is "This index requires about 35,700 leaf
> pages.
> " I have a basic understanding of the leaf structure of a nonclustered
> index,
> but I do not understand the value 35,700. How was 35,700 determined or
> calculated based off the given data?
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200606/1
Given the following SQL statement:
select title
from titles
where price between $20.00 and $30.00
The size of the table in rows and pages, the number of rows per page, and the
number of rows that the query returns:
1,000,000 rows (books)
190,000 are priced between $20 and $30
10 rows per page; pages 75 percent full; approximately 140,000 pages
There is a statement that I read which said:
Based upon a nonclustered index on price, title (and the table does not have
a clustered index) the query can perform a matching index scan, finding the
first page with a price of $20 via index pointers, and then scanning forward
on the leaf level until it finds a price more than $30. This index requires
about 35,700 leaf pages, so to scan the matching leaf pages requires about 6,
800 reads.
The part I do not understand is "This index requires about 35,700 leaf pages.
" I have a basic understanding of the leaf structure of a nonclustered index,
but I do not understand the value 35,700. How was 35,700 determined or
calculated based off the given data?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200606/1> The part I do not understand is "This index requires about 35,700 leaf
> pages.
> " I have a basic understanding of the leaf structure of a nonclustered
> index,
> but I do not understand the value 35,700. How was 35,700 determined or
> calculated based off the given data?
The number of leaf nodes in the non-clustered index cannot be calculated
from the data given. Storage requirements depend on the data types of the
key columns and, for variable length data, the average value length. It
seems the average title is about 50 characters, assuming a varchar data type
and smallmoney for price.
It appears to me the point of this indexing example is to demonstrate the
relative efficiency of a covering non-clustered index rather than how to
calculate space index requirements.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"cbrichards" <u3288@.uwe> wrote in message news:612e0f3c23791@.uwe...
>I am trying to understand an example of indexing I read about.
> Given the following SQL statement:
> select title
> from titles
> where price between $20.00 and $30.00
> The size of the table in rows and pages, the number of rows per page, and
> the
> number of rows that the query returns:
> 1,000,000 rows (books)
> 190,000 are priced between $20 and $30
> 10 rows per page; pages 75 percent full; approximately 140,000 pages
> There is a statement that I read which said:
> Based upon a nonclustered index on price, title (and the table does not
> have
> a clustered index) the query can perform a matching index scan, finding
> the
> first page with a price of $20 via index pointers, and then scanning
> forward
> on the leaf level until it finds a price more than $30. This index
> requires
> about 35,700 leaf pages, so to scan the matching leaf pages requires about
> 6,
> 800 reads.
> The part I do not understand is "This index requires about 35,700 leaf
> pages.
> " I have a basic understanding of the leaf structure of a nonclustered
> index,
> but I do not understand the value 35,700. How was 35,700 determined or
> calculated based off the given data?
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200606/1
Calculating leaf pages
I am trying to understand an example of indexing I read about.
Given the following SQL statement:
select title
from titles
where price between $20.00 and $30.00
The size of the table in rows and pages, the number of rows per page, and th
e
number of rows that the query returns:
1,000,000 rows (books)
190,000 are priced between $20 and $30
10 rows per page; pages 75 percent full; approximately 140,000 pages
There is a statement that I read which said:
Based upon a nonclustered index on price, title (and the table does not have
a clustered index) the query can perform a matching index scan, finding the
first page with a price of $20 via index pointers, and then scanning forward
on the leaf level until it finds a price more than $30. This index requires
about 35,700 leaf pages, so to scan the matching leaf pages requires about 6
,
800 reads.
The part I do not understand is "This index requires about 35,700 leaf pages
.
" I have a basic understanding of the leaf structure of a nonclustered index
,
but I do not understand the value 35,700. How was 35,700 determined or
calculated based off the given data?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200606/1> The part I do not understand is "This index requires about 35,700 leaf
> pages.
> " I have a basic understanding of the leaf structure of a nonclustered
> index,
> but I do not understand the value 35,700. How was 35,700 determined or
> calculated based off the given data?
The number of leaf nodes in the non-clustered index cannot be calculated
from the data given. Storage requirements depend on the data types of the
key columns and, for variable length data, the average value length. It
seems the average title is about 50 characters, assuming a varchar data type
and smallmoney for price.
It appears to me the point of this indexing example is to demonstrate the
relative efficiency of a covering non-clustered index rather than how to
calculate space index requirements.
Hope this helps.
Dan Guzman
SQL Server MVP
"cbrichards" <u3288@.uwe> wrote in message news:612e0f3c23791@.uwe...
>I am trying to understand an example of indexing I read about.
> Given the following SQL statement:
> select title
> from titles
> where price between $20.00 and $30.00
> The size of the table in rows and pages, the number of rows per page, and
> the
> number of rows that the query returns:
> 1,000,000 rows (books)
> 190,000 are priced between $20 and $30
> 10 rows per page; pages 75 percent full; approximately 140,000 pages
> There is a statement that I read which said:
> Based upon a nonclustered index on price, title (and the table does not
> have
> a clustered index) the query can perform a matching index scan, finding
> the
> first page with a price of $20 via index pointers, and then scanning
> forward
> on the leaf level until it finds a price more than $30. This index
> requires
> about 35,700 leaf pages, so to scan the matching leaf pages requires about
> 6,
> 800 reads.
> The part I do not understand is "This index requires about 35,700 leaf
> pages.
> " I have a basic understanding of the leaf structure of a nonclustered
> index,
> but I do not understand the value 35,700. How was 35,700 determined or
> calculated based off the given data?
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200606/1
Given the following SQL statement:
select title
from titles
where price between $20.00 and $30.00
The size of the table in rows and pages, the number of rows per page, and th
e
number of rows that the query returns:
1,000,000 rows (books)
190,000 are priced between $20 and $30
10 rows per page; pages 75 percent full; approximately 140,000 pages
There is a statement that I read which said:
Based upon a nonclustered index on price, title (and the table does not have
a clustered index) the query can perform a matching index scan, finding the
first page with a price of $20 via index pointers, and then scanning forward
on the leaf level until it finds a price more than $30. This index requires
about 35,700 leaf pages, so to scan the matching leaf pages requires about 6
,
800 reads.
The part I do not understand is "This index requires about 35,700 leaf pages
.
" I have a basic understanding of the leaf structure of a nonclustered index
,
but I do not understand the value 35,700. How was 35,700 determined or
calculated based off the given data?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200606/1> The part I do not understand is "This index requires about 35,700 leaf
> pages.
> " I have a basic understanding of the leaf structure of a nonclustered
> index,
> but I do not understand the value 35,700. How was 35,700 determined or
> calculated based off the given data?
The number of leaf nodes in the non-clustered index cannot be calculated
from the data given. Storage requirements depend on the data types of the
key columns and, for variable length data, the average value length. It
seems the average title is about 50 characters, assuming a varchar data type
and smallmoney for price.
It appears to me the point of this indexing example is to demonstrate the
relative efficiency of a covering non-clustered index rather than how to
calculate space index requirements.
Hope this helps.
Dan Guzman
SQL Server MVP
"cbrichards" <u3288@.uwe> wrote in message news:612e0f3c23791@.uwe...
>I am trying to understand an example of indexing I read about.
> Given the following SQL statement:
> select title
> from titles
> where price between $20.00 and $30.00
> The size of the table in rows and pages, the number of rows per page, and
> the
> number of rows that the query returns:
> 1,000,000 rows (books)
> 190,000 are priced between $20 and $30
> 10 rows per page; pages 75 percent full; approximately 140,000 pages
> There is a statement that I read which said:
> Based upon a nonclustered index on price, title (and the table does not
> have
> a clustered index) the query can perform a matching index scan, finding
> the
> first page with a price of $20 via index pointers, and then scanning
> forward
> on the leaf level until it finds a price more than $30. This index
> requires
> about 35,700 leaf pages, so to scan the matching leaf pages requires about
> 6,
> 800 reads.
> The part I do not understand is "This index requires about 35,700 leaf
> pages.
> " I have a basic understanding of the leaf structure of a nonclustered
> index,
> but I do not understand the value 35,700. How was 35,700 determined or
> calculated based off the given data?
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200606/1
Friday, February 10, 2012
Calculated Members Problem
1. I got the price and the qty in the data source. when I create the
calculated member Amount = Qty * price, I found out the total is equal to the
total qty * total price.
How can I define the calculated member Amount = summation of (qty *
price).
2. secondly, I would like to count how many order line. How can I do it in
the calculated members?
"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> 1. I got the price and the qty in the data source. when I create the
> calculated member Amount = Qty * price, I found out the total is equal to
the
> total qty * total price.
> How can I define the calculated member Amount = summation of (qty *
> price).
>
Define a measure with source column = Qty * price
> 2. secondly, I would like to count how many order line. How can I do it in
> the calculated members?
>
Try defining a mesaure on OrderID_OrderLineID with aggregate function
"Count". But it depends on the structure of the fact table
Francesco Anti
|||I defined Qty * price.
but my problem is the total sales = total qty * total price. It is wrong.
How can I define the total sales = total (qty * price)?
"Francesco Anti" wrote:
> "Kam" <Kam@.discussions.microsoft.com> wrote in message
> news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> the
> Define a measure with source column = Qty * price
> Try defining a mesaure on OrderID_OrderLineID with aggregate function
> "Count". But it depends on the structure of the fact table
> Francesco Anti
>
>
calculated member Amount = Qty * price, I found out the total is equal to the
total qty * total price.
How can I define the calculated member Amount = summation of (qty *
price).
2. secondly, I would like to count how many order line. How can I do it in
the calculated members?
"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> 1. I got the price and the qty in the data source. when I create the
> calculated member Amount = Qty * price, I found out the total is equal to
the
> total qty * total price.
> How can I define the calculated member Amount = summation of (qty *
> price).
>
Define a measure with source column = Qty * price
> 2. secondly, I would like to count how many order line. How can I do it in
> the calculated members?
>
Try defining a mesaure on OrderID_OrderLineID with aggregate function
"Count". But it depends on the structure of the fact table
Francesco Anti
|||I defined Qty * price.
but my problem is the total sales = total qty * total price. It is wrong.
How can I define the total sales = total (qty * price)?
"Francesco Anti" wrote:
> "Kam" <Kam@.discussions.microsoft.com> wrote in message
> news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> the
> Define a measure with source column = Qty * price
> Try defining a mesaure on OrderID_OrderLineID with aggregate function
> "Count". But it depends on the structure of the fact table
> Francesco Anti
>
>
Calculated Members Problem
1. I got the price and the qty in the data source. when I create the
calculated member Amount = Qty * price, I found out the total is equal to th
e
total qty * total price.
How can I define the calculated member Amount = summation of (qty *
price).
2. secondly, I would like to count how many order line. How can I do it in
the calculated members?"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> 1. I got the price and the qty in the data source. when I create the
> calculated member Amount = Qty * price, I found out the total is equal to
the
> total qty * total price.
> How can I define the calculated member Amount = summation of (qty *
> price).
>
Define a measure with source column = Qty * price
> 2. secondly, I would like to count how many order line. How can I do it in
> the calculated members?
>
Try defining a mesaure on OrderID_OrderLineID with aggregate function
"Count". But it depends on the structure of the fact table
Francesco Anti|||I defined Qty * price.
but my problem is the total sales = total qty * total price. It is wrong.
How can I define the total sales = total (qty * price)?
"Francesco Anti" wrote:
> "Kam" <Kam@.discussions.microsoft.com> wrote in message
> news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> the
> Define a measure with source column = Qty * price
>
> Try defining a mesaure on OrderID_OrderLineID with aggregate function
> "Count". But it depends on the structure of the fact table
> Francesco Anti
>
>
calculated member Amount = Qty * price, I found out the total is equal to th
e
total qty * total price.
How can I define the calculated member Amount = summation of (qty *
price).
2. secondly, I would like to count how many order line. How can I do it in
the calculated members?"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> 1. I got the price and the qty in the data source. when I create the
> calculated member Amount = Qty * price, I found out the total is equal to
the
> total qty * total price.
> How can I define the calculated member Amount = summation of (qty *
> price).
>
Define a measure with source column = Qty * price
> 2. secondly, I would like to count how many order line. How can I do it in
> the calculated members?
>
Try defining a mesaure on OrderID_OrderLineID with aggregate function
"Count". But it depends on the structure of the fact table
Francesco Anti|||I defined Qty * price.
but my problem is the total sales = total qty * total price. It is wrong.
How can I define the total sales = total (qty * price)?
"Francesco Anti" wrote:
> "Kam" <Kam@.discussions.microsoft.com> wrote in message
> news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> the
> Define a measure with source column = Qty * price
>
> Try defining a mesaure on OrderID_OrderLineID with aggregate function
> "Count". But it depends on the structure of the fact table
> Francesco Anti
>
>
Subscribe to:
Posts (Atom)