Query for daily sales by warehouse
Hi
I need a query for Daily sales by warehouse. I am only new to this and struggling with generating.
ideally it will look like the below. With no selection criteria as I would like to schedule the report to email out at the end of each day.
Warehouse Revenue GP GP%
NSW $xxxx $xxx 35%
Would someone mind helping
thanks
thankyou , But i have multiple warehouse and i dont want to use a selection criteria.
to expand on the original example
Warehouse Revenue GP GP%
NSW $xxxx $xxx 35%
QLD $xxx $xx 32%
VIC $xxx $xx 32%
Also the results should only show figures for the day the query is executed
Any help is appreciated.
Similar layout to this,except using query and whs code. the below is generated using sales analysis and customer group.
Similar Messages
-
Dear Experts,
I have developed the query for weekly sales report for the alert management to send out the report on every Monday as follow :
SELECT T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal] FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.[DocDate] between GetDate()-8 and GetDate()-1
The weekly report received on every Monday through email is without column total for the "Line Total".
Can the Sum of column "Line Total" to be included in the query ?
Thus, the auto send report on every Monday by alert management will display the total.
Thanks in advance for all your kind assistance.
Regards,
ClaraOk you want it at the bottom.......
then you must must try this if you are running query generator....
Else a good option is Crystal Report.
You need to only add Group Sum.......
SELECT T0.CardCode, T0.CardName, T0.DocDate, T1.ItemCode, T1.Dscription, T1.Quantity, T1.LineTotal FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.DocDate between GetDate()-8 and GetDate()-1
Union All
Select '','',Null, '','Total',Null, Sum(T1.LineTotal) FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.DocDate between GetDate()-8 and GetDate()-1
Regards,
Rahul -
Query for Total sales by customer
Hi,
I want to create a query for getting a total of all sales for all Customers for the date range entered by the user.
How can I do it?
JyotiIf I can add my thoughts. The query from Jyoti fails for me due to the Where statement. Try the following:
SELECT T0.CardName, T0.Address, T1.CreditLine, T2.PymntGroup as 'Payment Terms', T1.Balance, T0.DocTotal
FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCTG T2 ON T0.GroupNum = T2.GroupNum
WHERE T0.DocDate BETWEEN '[%0]' AND '[%1]'
Having said that I use the built in Sales Analysis report to get the sales by customer by date.
regards,
Ralph -
Query for Itemwise Sales Register
Hi Guys,
Below is the query i have used to run Sales Register.But we need the sales register based on item wise and those Excise Duty calculations are needed for item wise instead of total document wise.
Pls update the query ...
SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',L.Dscription,L.Quantity,L.Price,
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
(SELECT Avg(TaxRate) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ',
(SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ',
L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14
GROUP BY
M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal
ORDER BY
M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal
Regards, Vamsi.Hi Guys, Below is the query i have used to run Sales Register.But we need the sales register based on item wise and those Excise Duty calculations are needed for item wise instead of total document wise. Pls update the query ...
SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',
L.Dscription,L.Quantity,L.Price, (Select Sum(LineTotal)
FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)', (SELECT Avg(TaxRate)
FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ',
(SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ',
L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14
GROUP BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotalORDER BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal -
Query for Daily Payment Records against Multiple Payment Means
Hi Experts,
I've got this query to show daily payment details which related today's invoice only, however, if there are multiple payment means which linked to one invoice then it just shows last payment record only. Let say, Invoice no. 1 paid by three cheques and query shows last row of cheque amount only. Is it possible to shows multiple payment means against one invoice as well?
Thanks in advance for any help.
SELECT DISTINCT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T1.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T0.DocTotal
WHEN T1.TrsfrSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CashSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CreditSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CheckSum > 0 THEN T0.DocTotal - T0.PaidToDate
ELSE T0.DocTotal
END AS 'AR Sum',
CASE
WHEN T0.ObjType = 13 THEN 'ARIV'
WHEN T0.ObjType = 14 THEN 'ARCR'
ELSE 'N/A'
END AS 'Doc Type',
CASE
WHEN T1.Series = 12 THEN 'IPAY'
WHEN T1.Series = 15 THEN 'OPAY'
ELSE 'N/A'
END AS 'Doc Series',
T0.ObjType,
T1.Series,
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.TrsfrSum - T1.TrsfrSum
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.TrsfrSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'TrsfrSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CashSum - T1.CashSum
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.CashSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CashSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CheckSum - T1.CheckSum
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.CheckSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CheckSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CreditSum - T1.CreditSum
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.CreditSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CreditSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.TrsfrSum - T1.TrsfrSum
WHEN T1.TrsfrSum > T0.DocTotal THEN T0.PaidToDate
ELSE T1.TrsfrSum
END 'Paid To Date',
T1.JrnlMemo
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT2 T2 ON T1.DocNum = T2.DocNum AND T0.DocEntry = T2.DocEntry
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE DateDiff(D,T0.DocDate,GetDate())=0
ORDER BY T0.DocDate, T1.DocDate, 'CreditSum', 'CheckSum', 'CashSum', 'TrsfrSum', 'AR Sum'
Edited by: Won Gyu (Gerald) Lee on Feb 22, 2012 7:15 AM
Edited by: Won Gyu (Gerald) Lee on Feb 22, 2012 7:15 AM
Edited by: Won Gyu (Gerald) Lee on Feb 22, 2012 7:17 AMHi Gordon,
Thanks for reply and I've got your book which is being very helpful.
I tried and it seems to shows multiple payment list, however, there are all same value in 'CashSum', 'CheckSum', 'CreditSum', 'TrsfrSum' columns.
For example, if invoice link with one payment mean (cash:$10.00) then it shows like this.
'CashSum', 'CheckSum', 'CreditSum', 'TrsfrSum'
10.00 10.00 10.00 10.00
SELECT DISTINCT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T1.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T0.DocTotal
WHEN T1.TrsfrSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CashSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CreditSum > 0 THEN T0.DocTotal - T0.PaidToDate
WHEN T1.CheckSum > 0 THEN T0.DocTotal - T0.PaidToDate
ELSE T0.DocTotal
END AS 'AR Sum',
CASE
WHEN T0.ObjType = 13 THEN 'ARIV'
WHEN T0.ObjType = 14 THEN 'ARCR'
ELSE 'N/A'
END AS 'Doc Type',
CASE
WHEN T1.Series = 12 THEN 'IPAY'
WHEN T1.Series = 15 THEN 'OPAY'
ELSE 'N/A'
END AS 'Doc Series',
T0.ObjType,
T1.Series,
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.TrsfrSum - T1.TrsfrSum
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.TrsfrSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'TrsfrSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CashSum - T1.CashSum
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.CashSum > T0.DocTotal THEN T2.SumApplied
ELSE T2.SumApplied
END AS 'CashSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CheckSum - T1.CheckSum
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CreditSum > 0 THEN '0'
WHEN T1.CheckSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CheckSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.CreditSum - T1.CreditSum
WHEN T1.CashSum > 0 THEN '0'
WHEN T1.TrsfrSum > 0 THEN '0'
WHEN T1.CheckSum > 0 THEN '0'
WHEN T1.CreditSum > T0.DocTotal THEN T0.PaidToDate
ELSE T2.SumApplied
END AS 'CreditSum',
CASE
WHEN T1.JrnlMemo = 'Cancelled' THEN T1.TrsfrSum - T1.TrsfrSum
WHEN T1.TrsfrSum > T0.DocTotal THEN T0.PaidToDate
ELSE T1.TrsfrSum
END 'Paid To Date',
T1.JrnlMemo
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.DocNum = T1.DocNum
LEFT JOIN RCT2 T2 ON T0.DocEntry = T2.DocEntry
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE T0.DocDate = [%0]
ORDER BY T0.DocDate, T1.DocDate, 'CreditSum', 'CheckSum', 'CashSum', 'TrsfrSum', 'AR Sum' -
Hi,
This is my First table: REPORT
with report as (
select 'vendor_1' as vendor,to_date('1/1/2012','DD/MM/YYYY') supply_date, 'customer_1'as customer,'item_1' as item1, 110 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/3/2012','MM/DD/YYYY') supply_date,'customer_1'as customer, 'item_1' as item1,120 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/3/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item1,130 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/4/2012','MM/DD/YYYY') supply_date,'customer_1'as customer, 'item_1' as item1,140 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/10/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item ,200as cost from dual union all
select 'vendor_1' as vendor,to_date('1/23/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item,0 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/6/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,160 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/7/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,170 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/8/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,180 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/9/2012','MM/DD/YYYY') supply_date,'customer_2'as customer,'item_1' as item1,190 as cost from dual union all
select 'vendor_1' as vendor,to_date('1/20/2012','MM/DD/YYYY') supply_date,'customer_2'as customer,'item_1' as item1,300 as cost from dual)
THIS IS MY SECOND TABLE: TEMP_WEEK
WITH temp_week a s(
SELECT '01/01/2012 to 07/01/2012' AS week from dual union all
SELECT '08/01/2012 to 14/01/2012' AS week from dual union all
SELECT '15/01/2012 to 21/01/2012' AS week from dual union all
SELECT '22/01/2012 to 28/01/2012' AS week from dual union all
SELECT '29/01/2012 to 31/01/2012' AS week from dual)
To find weekly sales i have wrote below query:
SELECT week,vendor,customer,SUM (cost)
FROM ( SELECT week,vendor,customer,SUM (cost) cost
FROM (SELECT CASE
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 1 AND 7 THEN
'01/01/2012 to 07/01/2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 8 AND 14 THEN
'08/01/2012 to 14/01/2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 15 AND 21 THEN
'15/01/2012 to 21/01/2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 22 AND 28 THEN
'22/01/2012 to 28/01/2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 29 AND 31 THEN
'29/01/2012 to 31/01/2012'
END
week,vendor,customer,cost
FROM report)
GROUP BY week, vendor, customer
UNION ALL
SELECT tw.week,vendor,customer,0
FROM ( SELECT week,vendor,customer,SUM (cost) cost
FROM (SELECT CASE
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 1 AND 7 THEN
'01/01/2012 to 07/01/2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 8 AND 14 THEN
'08/01/2012 to 14/01/2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 15 AND 21 THEN
'15/01/2012 to 21/01/2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 22 AND 28 THEN
'22/01/2012 to 28/01/2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 29 AND 31 THEN
'29/01/2012 to 31/01/2012'
END
week,vendor,customer,cost
FROM report)
GROUP BY week, vendor, customer),temp_week tw)
GROUP BY week, vendor, customer
ORDER BY vendor, customer, week ;
with above query i am getting below output:
with output as(
select '01/01/2012 to 07/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 500 as cost from dual union all
select '08/01/2012 to 14/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 200 as cost from dual union all
select '15/01/2012 to 21/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 0 as cost from dual union all
select '22/01/2012 to 28/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 0 as cost from dual union all
select '29/01/2012 to 31/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 0 as cost from dual union all
select '01/01/2012 to 07/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 330 as cost from dual union all
select '08/01/2012 to 14/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 370 as cost from dual union all
select '15/01/2012 to 21/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 300 as cost from dual union all
select '22/01/2012 to 28/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 0 as cost from dual union all
select '29/01/2012 to 31/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 0 as cost from dual )
Clearly I have used cross join. But I want to get same output with some other way. I dont want to use cross join and Union
please help me in this.DUPLICATE!
SQL Query help. -
Query for Sales Order Analysis
Dear Experts
I have written a Query for Sales Order Analysis and would like to have help on this.
The query is used for generating daily report for Sales Order on number of documents (Sales Order), total amount of sales orders and total GP of Sales Order. The query is written as below:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum] ORDER BY T0.[DocNum]
where U_Total_GP is a UDF for storing the GP of each order.
After executing the query, a selection criteria of date appears and after a date is selected, the report shown information required. However, the query does not calculate column total for total amount and total GP. Although I know the total for each column can be displayed by pressing "Ctrl" + Click on the column title, it would have to be done from time to time.
Therefore, I would like to modify my query in order to calculate the column totals when executed. Are there any suggestions for this?
Thank you
Regards
EltonHi Elton,
Try this:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
Union ALL
SELECT '', SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0]
ORDER BY T0.[DocNum]
Thanks,
Gordon -
Daily Sales Total Comparison Query
Hi Experts,
I'm trying to make a query to get daily sales total for week and wish to make a graph.
However, if there is no figures in credit note or Down payment invoice or invoice then query seems not showing any figures for particular date.
I would be appreciated if anyone help this.
SELECT DISTINCT
GetDate(),
SUM (DISTINCT T0.DocTotal) AS 'Daily INV Sum',
SUM (DISTINCT T2.DocTotal) AS 'Daily DT INV Sum',
SUM (DISTINCT T1.DocTotal*-1) AS 'Daily CR Sum',
SUM (DISTINCT T0.DocTotal) + SUM (DISTINCT T2.DocTotal) - SUM (DISTINCT T1.DocTotal) AS 'Daily Sales Total'
FROM OINV T0, ORIN T1, ODPI T2
WHERE DateDiff(D,T0.DocDate,GetDate())=0 AND DateDiff(D,T1.DocDate,GetDate())=0 AND DateDiff(D,T2.DocDate,GetDate())=0
UNION ALL
SELECT
DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 1, 0)),
SUM (DISTINCT T0.DocTotal) AS 'Daily Sales Sum',
SUM (DISTINCT T2.DocTotal) AS 'Daily DT INV Sum',
SUM (DISTINCT T1.DocTotal*-1) AS 'Daily CR Sum',
SUM (DISTINCT T0.DocTotal) + SUM (DISTINCT T2.DocTotal) - SUM (DISTINCT T1.DocTotal) AS 'Daily Sales Total'
FROM OINV T0, ORIN T1, ODPI T2
WHERE T0.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 1, 0)) AND T1.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 1, 0)) AND T2.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 1, 0))
UNION ALL
SELECT
DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 2, 0)),
SUM (DISTINCT T0.DocTotal) AS 'Daily Sales Sum',
SUM (DISTINCT T2.DocTotal) AS 'Daily DT INV Sum',
SUM (DISTINCT T1.DocTotal*-1) AS 'Daily CR Sum',
SUM (DISTINCT T0.DocTotal) + SUM (DISTINCT T2.DocTotal) - SUM (DISTINCT T1.DocTotal) AS 'Daily Sales Total'
FROM OINV T0, ORIN T1, ODPI T2
WHERE T0.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 2, 0)) AND T1.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 2, 0)) AND T2.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 2, 0))
UNION ALL
SELECT
DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 3, 0)),
SUM (DISTINCT T0.DocTotal) AS 'Daily Sales Sum',
SUM (DISTINCT T2.DocTotal) AS 'Daily DT INV Sum',
SUM (DISTINCT T1.DocTotal*-1) AS 'Daily CR Sum',
SUM (DISTINCT T0.DocTotal) + SUM (DISTINCT T2.DocTotal) - SUM (DISTINCT T1.DocTotal) AS 'Daily Sales Total'
FROM OINV T0, ORIN T1, ODPI T2
WHERE T0.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 3, 0)) AND T1.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 3, 0)) AND T2.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 3, 0))
UNION ALL
SELECT
DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 4, 0)),
SUM (DISTINCT T0.DocTotal) AS 'Daily Sales Sum',
SUM (DISTINCT T2.DocTotal) AS 'Daily DT INV Sum',
SUM (DISTINCT T1.DocTotal*-1) AS 'Daily CR Sum',
SUM (DISTINCT T0.DocTotal) + SUM (DISTINCT T2.DocTotal) - SUM (DISTINCT T1.DocTotal) AS 'Daily Sales Total'
FROM OINV T0, ORIN T1, ODPI T2
WHERE T0.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 4, 0)) AND T1.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 4, 0)) AND T2.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 4, 0))
UNION ALL
SELECT
DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 5, 0)),
SUM (DISTINCT T0.DocTotal) AS 'Daily Sales Sum',
SUM (DISTINCT T2.DocTotal) AS 'Daily DT INV Sum',
SUM (DISTINCT T1.DocTotal*-1) AS 'Daily CR Sum',
SUM (DISTINCT T0.DocTotal) + SUM (DISTINCT T2.DocTotal) - SUM (DISTINCT T1.DocTotal) AS 'Daily Sales Total'
FROM OINV T0, ORIN T1, ODPI T2
WHERE T0.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 5, 0)) AND T1.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 5, 0)) AND T2.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 5, 0))
UNION ALL
SELECT
DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 6, 0)),
SUM (DISTINCT T0.DocTotal) AS 'Daily Sales Sum',
SUM (DISTINCT T2.DocTotal) AS 'Daily DT INV Sum',
SUM (DISTINCT T1.DocTotal*-1) AS 'Daily CR Sum',
SUM (DISTINCT T0.DocTotal) + SUM (DISTINCT T2.DocTotal) - SUM (DISTINCT T1.DocTotal) AS 'Daily Sales Total'
FROM OINV T0, ORIN T1, ODPI T2
WHERE T0.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 6, 0)) AND T1.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 6, 0)) AND T2.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 6, 0))
UNION ALL
SELECT
DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 7, 0)),
SUM (DISTINCT T0.DocTotal) AS 'Daily Sales Sum',
SUM (DISTINCT T2.DocTotal) AS 'Daily DT INV Sum',
SUM (DISTINCT T1.DocTotal*-1) AS 'Daily CR Sum',
SUM (DISTINCT T0.DocTotal) + SUM (DISTINCT T2.DocTotal) - SUM (DISTINCT T1.DocTotal) AS 'Daily Sales Total'
FROM OINV T0, ORIN T1, ODPI T2
WHERE T0.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 7, 0)) AND T1.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 7, 0)) AND T2.DocDate = DATEADD(dd, 0, DATEADD(dd, DATEDIFF(dd, 0, GetDate()) - 7, 0))Could you let me know how to make pivot query?
AR INV TOTAL | AR Down Payment Total | AR Credit Total | (AR INV TOTAL+AR DP TOTAL-AR CREDIT TOTAL)
Today's Sales
Yesterday
Until Week Before -
Query for Sales order and corr.AR Invoice Info
Hi,
I need to write a query which gives the flollowing sales order info along with the coressponding AR invoices info
Sales Order columns reqd:
OPERATING_UNIT
ORDER_NUMBER
CUSTOMER_NUM
CUSTOMER_NAME
ORDERED_DATE
FLOW_STATUS_CODE
TOTAL_ORDER_AMOUNT
AR invoice columns reqd for the sales orders:
Invoice number,
Invoice date,
Invoice Total.
Can anyone help me out with this?
Thanks,
AshHi Ash,
There are some issues that must be defined before you have the exact query.
Do you have freight charges or non-inclusive tax? If you have, freight charges and tax amounts must be included?
Depending on you grouping rule, you can have lines from more than one order in a single invoice. In this case, as invoice amount you want the sum of all lines, or only the lines from that order?
Below is an example using two views. It assumes that grouping rules split lines from different order into different invoices.
Hope it helps,
Ketter Ohnes
create or replace view order_summary as
select oh.org_id,
oh.ORDER_NUMBER,
oh.header_id,
ott.name tt_name,
ca.account_number,
p.party_name,
oh.ordered_date,
oh.flow_status_code,
sum(ol.ordered_quantity*ol.unit_selling_price) total,
sum(ol.tax_value) tax,
(select sum(operand)
from OE_PRICE_ADJUSTMENTS_v x
where x.header_id = oh.header_id
and x.adjustment_type_code='FREIGHT_CHARGE') freight_charge
from oe_order_headers_all oh,
oe_order_lines_all ol,
hz_cust_accounts ca,
hz_parties p,
oe_transaction_types_tl ott
where ol.header_id=oh.header_id
and oh.sold_to_org_id = ca.cust_account_id
and ca.party_id = p.party_id
and oh.order_type_id = ott.transaction_type_id
and ott.language =
(select language_code
from fnd_languages
where installed_flag = 'B')
group by oh.org_id,
oh.header_id,
oh.ORDER_NUMBER ,
ott.name,
ca.account_number,
p.party_name,
oh.ordered_date,
oh.flow_status_code;
create or replace view invoice_summary as
select a.interface_header_context,
a.trx_date,
a.trx_number,
b.interface_line_attribute1,
b.interface_line_attribute2 tt_name,
a.customer_trx_id,
sum(b.extended_amount) invoice_total
from ra_customer_trx_all a,
ra_customer_trx_lines_all b
where a.customer_trx_id = b.customer_trx_id
and b.interface_line_context = 'ORDER ENTRY'
and b.line_type in ('LINE','FREIGHT')
group by a.interface_header_context,
a.trx_date, a.trx_number,
b.interface_line_attribute1,
b.interface_line_attribute2,
a.customer_trx_id;
select *
from order_summary o,
invoice_summary i
where o.order_number between :1 and :2
and o.order_number = i.interface_line_attribute1
and o.tt_name = i.tt_name; -
Query for Sales Order and AR Invoice Information
Hi,
I need to write a query which gives the flollowing sales order info along with the coressponding AR invoices info
Sales Order columns reqd:
OPERATING_UNIT
ORDER_NUMBER
CUSTOMER_NUM
CUSTOMER_NAME
ORDERED_DATE
FLOW_STATUS_CODE
TOTAL_ORDER_AMOUNT
AR invoice columns reqd for the sales orders:
Invoice number,
Invoice date,
Invoice Total.
Can anyone help me out with this?
Thanks,
AshHi Ash,
Table RA_CUSTOMER_TRX_ALL can be joined to RA_CUSTOMER_TRX_LINES_ALL table through CUSTOMER_TRX_ID column. The table RA_CUSTOMER_TRX_LINES_ALL.INTERFACE_LINE_ATTRIBUTE6 = OE_ORDER_LINES_ALL.LINE_ID. And from the LineId, you can get the HeaderId os the OE_ORDER_HEADERS_ALL table.
You must have visualized the query by now.
Thanks
Sumit -
No Daily Sales/Trend Report for today?
Has anyone received your iTunes Connect Daily Sales/Trend Report for today (1/25/10)? I have not received mine yet. First time it hasn't been up at this hour.
It usually arrives at 2:30am (it's 9:30am here now) or if it's delayed, usually in another region, there's a note in big red text on the reports page.As I recall (back when I only had a few apps just starting in the store), yes, no daily sales means no daily report. Wait for the weekly report to confirm.
-
Daily sales by month and cumulative sales for year
Hi Experts,
I have a reporting requirement where I have to show daily sales by month and cumulative daily sales for particular month for the year.
e.g. If the current month is January then my result shows fine. see below
Calendar Day
Net Sales
Target
Sales Year
Actual
Target
01/01/2014
100
90
01/01/2014
100
90
02/01/2014
200
180
02/01/2014
300
270
03/01/2014
300
290
03/01/2014
600
560
04/01/2014
400
350
04/01/2014
1000
910
But If I am in the month of Feb and I want to show sales for the month and cumulative sales for the year for just Feb but instead of showing cumulative total from 01/01/2014 to end of Feb it starts again at begining of Feb - See below
e.g.
Calendar Day
Net Sales
Target
Sales Year
Actual
Target
01/02/2014
200
190
01/02/2014
200
190
02/02/2014
400
380
02/02/2014
600
570
03/02/2014
600
590
03/02/2014
1200
1160
04/02/2014
800
750
04/02/2014
2000
1910
Expected Result - sales for the year shoud show cumulative result from 01/01/2014 - 31/12/2014
Calendar Day
Net Sales
Target
Sales Year
Actual
Target
01/02/2014
200
190
01/02/2014
1200
1100
02/02/2014
400
380
02/02/2014
1600
1480
03/02/2014
600
590
03/02/2014
2200
2070
04/02/2014
800
750
04/02/2014
3000
2820
How do I achive this?
please help.What else you need?
looks like you got #working days for the month, use that metric as of jan 15th -
Query for details of Sale order , Invoice and COGS
I Need the report cointing following based on month & Business partner
Sale order, Sale Amount, Due date, Invoice Amount, Last Invoice date, COGS amountHi Anantha,
Please check below link and modify according to your requirement.
Sales Order Query for in SAP B1
Query - Sales Orders linked to Deliveries
My Top SQL Queries for SAP Business One
Hope this helps
Regards::::
Atul Chakraborty -
Hi All,
Greetings.
I have two queries namely,
1.Query for cancelled requisitions and
2.Query for Internal Requisitions without Internal Sales Orders.
I was on a task to combine those two queries..
Can we do that? if so, please help me do that..
Thanks in Advance,
Bhaskar.Hi All,
Greetings.
I have two queries namely,
1.Query for cancelled requisitions and
2.Query for Internal Requisitions without Internal Sales Orders.
I was on a task to combine those two queries..
Can we do that? if so, please help me do that..
Thanks in Advance,
Bhaskar. -
Query for Opening Stock + Purchase Qty + Sales Qty
Hi ,
Can anyboday help me by how to develop a query for the following requirement. If any custom query is available please provide me .We are working on SBO 2007B PL 8. The required report structure is
ItemNo ***OpeningStock**** Purchase ********* Sales****
(Batchwise)** Qty*** Value ****Qty** Value ***Qty***Value
Thanks & Regards
SriniHi Srini,
I found this on the forum, see if it helps you;
select b.Itemcode,b.Item_Description,b.UOM, b.rate as Rate,b.Opening_Stock,b.Receipt,b.Issue, b.Material_Revalue,b.Closing_Stock,b.Closing_Value from (select *,(case closing_stock when 0 then 0 else(Closing_Value/Closing_Stock)end) as Rate from( SELECT T0.Itemcode as 'Itemcode' ,min(T0.Dscription) as 'Item_Description', max(T1.InvntryUom) as UOM, (isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<'[%0]' and O1.transtype in (58,59,20,16,67,-2)),0) - isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<'[%0]' and O1.transtype in (58,21,19,60,15,67,-2,13)),0)+ (isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.transtype in (-2)),0) - isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.transtype in (-2)),0)))as Opening_Stock, (isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.inqty>0 and O1.transtype in (20,18)),0) + isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.inqty>0 and O1.transtype in (67)),0) + isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.inqty>0 and O1.transtype in (58,59,16,14)),0)) as Receipt, (isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.outqty>0 and O1.transtype in (13,15)),0) + isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.outqty>0 and O1.transtype in (67)),0)+ isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.outqty>0 and O1.transtype in (58,60,21,19)),0)) as Issue, isnull((select sum(Transvalue) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<='[%1]' and O1.transtype in (162)),0) as Material_Revalue, (isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<='[%1]' and O1.transtype in (58,59,20,16,14,19,67,-2)),0) - isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<='[%1]' and O1.transtype in (58,21,19,60,15,67,-2,13)),0))as Closing_Stock, isnull((select sum(Transvalue) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<='[%1]' and O1.transtype in (58,18,-2,67,59,20,16,14,15,13,21,19,60,69,162)),0) as Closing_Value FROM OINM T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITW T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OITB B1 ON T1.ItmsGrpCod=B1.ItmsGrpCod where ((B1.ItmsGrpNam>='[%2]' and B1.ItmsGrpNam<='[%3]') or ('[%2]'='' and '[%3]'='')) GROUP BY T1.itemcode,T0.Itemcode )a Where (a.Opening_Stock + a.Receipt + a.Issue + a.Material_Revalue + a.Closing_Stock + a.Closing_Value) <> 0 )b
Thanks,
Joseph
Maybe you are looking for
-
How do I update a file in an Applet's JAR file from the Applet code
Here's my problem. My applet is using a serializable history data in which I am storing in the applet's JAR file. When I run the applet, I read the file with "getResourceAsStream()" and run my program with that hist data. When my applet is closed, I
-
HT1918 how can i setup my account without a credit card
how can i setup my account without a credit card
-
Copying files from a dead hard drive
How do I repopulate files (Touchsmart 600) from my old hard drive? I have the files on an external drive and have a desktop copy on the newly formatted machine. Tried recovery and restore options with no luck. any help is appreciated.
-
PDF icon images appear on desktop, but not in folders?
I just updated to Windows 7. Before the update I could only view pdf icons on the desktop and inside folders would be a screenshot pdf icon image of the file. This was very helpful when using a lot of pdf files. NOW, after installing Windows 7, I hav
-
Add Device issue with Bluetooth!
Hi, Earlier, my laptop could not detect any Bluetooth device, however; reading a post on MS community on the subject, I uninstalled all the devices under Bluetooth as shown in the Device Manager. After restart my Bluetooth could detect my devices and