Query for top 5 items
Hi All,
Looking for a query that would return the top 5 sales items along with sales values, between a date range
Thanks
Ranjit Krishnan
Hi,
You may try this if Credit Memos do not need to be included:
SELECT TOP 5 T1.ItemCode, MAX(T1.Dscription) as 'Item Description', SUM(T1.LineTotal) as 'Amount(LC)'
FROM dbo.OINV T0
INNER JOIN dbo.INV1 T1 ON T1.DocENtry = T0.DocENtry
WHERE t0.docdate >= [%0\] and t0.docdate <= [%1\] AND t0.doctype = 'I'
GROUP BY T1.ItemCode
Order by SUM(T1.LineTotal) DESC
Thanks,
Gordon
Similar Messages
-
Oracle query for top two salary of each group departmentwise
oracle query for top two salary departmentwise
sigh...
But anyway,
Top-n queries:
http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2853107469873
and ofcourse lots of 'em here on OTN... -
SQL Query for TOP 10 Average CPU
Have a SCOM Report request for a line graph showing top 10 average CPU for a group of servers. I have a query that will show all of the servers in a group for the last day, with the average CPU by hour. How can I extend the SQL query to only select the TOP
10 average CPU from the group? Here is the Query I have:
SELECT
vPerf.DateTime,
vPerf.SampleCount,
cast(vPerf.AverageValue as numeric(10,2)) as AverageCPU,
vPerformanceRuleInstance.InstanceName,
vManagedEntity.Path,
vPerformanceRule.ObjectName,
vPerformanceRule.CounterName
FROM Perf.vPerfHourly AS vPerf INNER JOIN
vPerformanceRuleInstance ON vPerformanceRuleInstance.PerformanceRuleInstanceRowId = vPerf.PerformanceRuleInstanceRowId INNER JOIN
vManagedEntity ON vPerf.ManagedEntityRowId = vManagedEntity.ManagedEntityRowId INNER JOIN
vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId
WHERE
vPerf.DateTime >= DATEADD(Day, -1, GetDate())
AND vPerformanceRule.ObjectName like '%Processor Information%'
AND vPerformanceRuleInstance.InstanceName = '_Total'
AND (vPerformanceRule.CounterName IN ('% Processor Time'))
AND (vManagedEntity.Path IN (SELECT dbo.vManagedEntity.Name
FROM dbo.vManagedEntity INNER JOIN
dbo.vRelationship On dbo.vManagedEntity.ManagedEntityRowId = dbo.vRelationship.TargetManagedEntityRowId INNER JOIN
dbo.vManagedEntity As CompGroup On dbo.vRelationship.SourcemanagedEntityRowId = CompGroup.ManagedEntityRowId
WHERE CompGroup.DisplayName = 'bemis ibb prod'
ORDER BY path, vPerf.DateTime
Results
DateTime
SampleCount
AverageCPU
InstanceName
Path
ObjectName
CounterName
2/26/15 3:00 PM
2
1.98
_Total
servername.corp.com
Processor Information
% Processor Time
2/26/15 4:00 PM
2
2.09
_Total
servername.corp.com
Processor Information
% Processor Time
2/26/15 5:00 PM
2
1.72
_Total
servername.corp.com
Processor Information
% Processor Time
2/26/15 6:00 PM
2
1.83
_Total
servername.corp.com
Processor Information
% Processor Time
Thanks in Advance!
Mike HanlonHi
Sql Query
SELECT TOP 10
vPerf.DateTime,
vPerf.SampleCount,
cast(vPerf.AverageValue as numeric(10,2)) as AverageCPU,
vPerformanceRuleInstance.InstanceName,
vManagedEntity.Path,
vPerformanceRule.ObjectName,
vPerformanceRule.CounterName
FROM Perf.vPerfHourly AS vPerf INNER JOIN
vPerformanceRuleInstance ON vPerformanceRuleInstance.PerformanceRuleInstanceRowId = vPerf.PerformanceRuleInstanceRowId
INNER JOIN
vManagedEntity ON vPerf.ManagedEntityRowId = vManagedEntity.ManagedEntityRowId INNER JOIN
vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId
WHERE
vPerf.DateTime >= DATEADD(Day, -1, GetDate())
AND vPerformanceRule.ObjectName like '%Processor Information%'
AND vPerformanceRuleInstance.InstanceName = '_Total'
AND (vPerformanceRule.CounterName IN ('% Processor Time'))
AND (vManagedEntity.Path IN (SELECT dbo.vManagedEntity.Name
FROM dbo.vManagedEntity INNER JOIN
dbo.vRelationship On dbo.vManagedEntity.ManagedEntityRowId = dbo.vRelationship.TargetManagedEntityRowId INNER
JOIN
dbo.vManagedEntity As CompGroup On dbo.vRelationship.SourcemanagedEntityRowId = CompGroup.ManagedEntityRowId
WHERE CompGroup.DisplayName = 'bemis ibb prod'
ORDER BY path, vPerf.DateTime
Regards
sridhar v -
Hi,
We are trying to create a query for the open items (purchase orders ) in order to add some fields useful for users.
Would you be able to advise with the query needed to show us only the open items?
Best regards,
MBHi,
Try this one:
Select distinct t1.cardcode as Vendor, t1.CardName as Name, t1.docnum as PO#, t0.itemcode, t0.Dscription, t0.OpenQty as 'Open Qty', t0.linenum Row#, t1.DocCur as Currency, t0.price as 'Purchase Price', t0.whscode, t1.taxdate as "PO Date"
from dbo.por1 t0
inner join dbo.opor t1 on t1.docentry = t0.docentry
where t1.DocType = 'I' and t0.linestatus = 'O'
order by t1.docnum Desc, t0.linenum
Thanks,
Gordon -
Standard Query for Top 10 queries and Users
Hi Experts,
Is there any query which gives the details like ,
1. Top 10 queries executed in a month
2. Top 10 users ( By no of queries executed )
Regards,
Bhadri M.1. Top 10 queries executed in a month
Use Query 0TCT_MCA1_Q0142.
In this report you will have to filter variable BI Object to Queries and also it gives stats for the last 30 days, you have have to remove the SAP User exit variable in case you do not want to use the 30 days option. And then you will have to define Condition for Top 10.
2. Top 10 users ( By no of queries executed )
Use Query 0TCT_MCA1_Q0141.
Similarly you have to modify this query.
-Neelesh -
Query for top 10 selling products and their current stock
Hi ppl
I am using the sales overview cube 0SD_C03 to get top 10 selling products. What I want is to get the current stock available of the top 10 products from Material Stocks/Movements cube 0IC_C03. From what I know, we have to make a multiprovider to get this information. Can anyone guide me how to go about it?Hello Javed,
You can use Replacement path for this.
1.Create a report for Top 10 Products in InfoCube 0SD_C03 - Exampls Report A
2.Create another report with Stock and use a variable for Product with processing type replacement path in InfoCube0IC_C03 - Example Report B
3. In Report B and assing the Report A to this variable.
When you execute the Report B it will execute the Report A in background and displays it in Report B.
Hope it helps,
thanks
Chandran -
Using SQL Query for page item source does not insert populated value
Hi All,
Following are the attribute details of a certain page item on an edit form:
Display As: Text Field
Page Item Source Type: SQL Query
Source value Expression: SELECT a from tab where id = 'ABC'
Although the field appears populated on the screen, but the value is not inserted in the table.
Can anyone help on this?
Thanks in advance,
AnnieAnnie:
One solution is to define a pl/sql function that given a date will return the 'run-date'. Something like create or replace function get_prod_date(p_date in date) return date is
retval date;
begin
select run_date into retval from tab_x where run_date=p_date;
return retval;
end;Change the Source Type for the page-item back to 'Database Column'
Set Source value or expression to the 'database column name'
Set 'Post calculation computation' to be
get_prod_date(:pxx_date)
Varad -
Query for Billable item form MTL_SYSTEM_ITEMS_B for BOM billing item
Hi All,
I want to write query to get billing item from mtl_system_items_b for BOM ...Can anyone give me the idea for accessing the billing item..
In BOM
Routings - Resources(form) - Billing Item (Field) and Outside Processing Item (Field)LOV...i Want to know query to access these items..
Thanks
Raman Sharma
Edited by: 929841 on Apr 24, 2012 6:06 AMObtain FRD log file to find out why the trigger is fired twice.
R12: Forms Runtime Diagnostics (FRD), Tracing And Logging For Forms In Oracle Applications (Doc ID 438652.1)
Steps To Take FRD Trace in 11.5.10 & R12 (Doc ID 867943.1)
R12: How To Create An FRD (Forms Runtime Diagnostic) Log Using Forms 10g (Doc ID 445166.1)
How To Collect And Use Forms Trace (FRD) in Oracle Applications Release 12 (Doc ID 373548.1)
Thanks,
Hussein -
Warranty related query for sales item
hi I need a report for checking an sales item is under warranty or not & also I want to know the status of the products which comes under warranty is in open state or closed state Regards, K.Ramasamy
Hi,
Try this query:
SELECT T0.[ItemCode], T0.[ItemName], T1.[TmpltName], T1.[Deleted] FROM OITM T0 inner join OCTT T1 on T0.[WarrntTmpl] = T1.[TmpltName] WHERE T0.[SellItem] = 'y'
Thanks. -
Hi Experts..
I need a query to find the total items sold in a particular period for an particular item.
Pls help me in finding the query.
Regards,
Vamsi.
Edited by: Parimis on Jan 20, 2010 5:10 AMHi Vamsi,
Check the thread,
Help With Monthly Sales Query
Regards,
Madhan. -
MDX Query for Top 10 in SSAS Project
Hi Guys,
Please I need an MDX query that will help me calculate Top 10 inside the SSAS project.
Your help will be greatly appreciated.
Thanks
meHi,
I know nothing about PowerView and PerformancePoint Server but I played with Excel and I am able to use the named set I created. Here are the steps which I followed.
1 - Create the named set. Remember... this name set appears inside the dimension which you use as the first parameter inside TOPCOUNT function.
2 - Deploy the cube and perform a process full.
3 - Navigate to PowerPivot ribbon and click on PowerPivot Window.
4 - Choose From Database > From Analysis Services or PowerPivot. Specify the necessary SSAS server credentials and connect to the Cube which you are interested.
When it comes to the MDX query design window you construct your MDX code in SSMS and copy that code. You also can use the design mode as well. In this case you have to toggle the "design mode" option and enter to manual mode which you can type
your MDX code. Here is a screenshot of that.
5 - Validate your query and click Finish. Once the data is in you can create your power pivot report. Here is an example.
I hope this helps to troubleshoot your issue.
Best regards...
Chandima Lakmal Fonseka -
Query for exact item name for CAL required
Hi,
We are e-businessoft, reseller for Microsoft softwares.
One of the customer has recently purchased windows server and now wants to purchase some user CALs. Few users will do mstsc of WinServer from within the
premises and few customers will do the mstsc from remote location, a different city. Remote user will login via internet connection into the LAN and then do mstsc
of WinServer.
Please tell me exactly what products has to be purchased to facilitate this. I have suggested the below:
1. WinSvrCAL 2012 SNGL OLP NL UsrCAL
2. WinRmtDsktpSrvcsCAL 2012 SNGL OLP NL UsrCAL
If this is correct, then please guide on how exactly this works? For example, The user doing mstsc from within premises requires item 1 only and users doing mstsc
from different city requires item 2 only, or both 1 and 2 is required in both case.
The terminal server services gives a countdown of 120 days from date of installation and ultimately expires and all connections thru mstsc stops. And then the
server is reinstalled. So one major concern is whether purchase of these CALs will stop this inconvinience for ever?
Please reply asap. CAL requirement is very urgent but can not proceed unless this clarity comes from you.Hi,
Resellers should contact MSFT Partner Support for assistance.
In general, the scenario you describe requires both Windows Server CAL and also RDS CAL for each user/device.
This is because an RDS/TS CAL is required for correctly licensed use of RDS/TS, and in addition, because RDS/TS is used to gain access to Windows Server services/features, a Windows Server CAL is also required.
(there are different scenarios which may apply, depending upon the edition of Windows Server being used, and also, it may be less expensive, depending on the size/scale of the scenario, to instead consider CAL Suite options)
(also, note that if the Windows Server is offering MS Office, that requires Office licensing to be addressed. Also consider if the RDS/TS will allow the users/devices to consume MS Exchange or MS SharePoint or MS SQL, additional CALs for those products may
be required)
Don
(Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable.
This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!) -
Performance of query for getting item revisions
Hi All,
The following query took several minutes in an environment with about 7,500,000 item revisions :
SELECT
MIR.INVENTORY_ITEM_ID
, MSI.CONCATENATED_SEGMENTS ITEM_NUMBER
, MIR.ORGANIZATION_ID
, MP.ORGANIZATION_CODE
FROM
MTL_ITEM_REVISIONS_VL MIR
, MTL_PARAMETERS MP
, MTL_SYSTEM_ITEMS_VL MSI
WHERE
(MIR.INVENTORY_ITEM_ID = p_Item_ID OR MSI.CONCATENATED_SEGMENTS = p_Item_Number)
AND (MIR.ORGANIZATION_ID = p_Org_ID OR MP.ORGANIZATION_CODE = p_Org_Code)
AND MP.ORGANIZATION_ID = MIR.ORGANIZATION_ID
AND MIR.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND MIR.ORGANIZATION_ID = MSI.ORGANIZATION_ID ORDER BY EFFECTIVITY_DATE, REVISION DESC;
If changing this query to the following, it takes less than a second:
SELECT
MIR.INVENTORY_ITEM_ID
, MSI.CONCATENATED_SEGMENTS ITEM_NUMBER
, MIR.ORGANIZATION_ID
, MP.ORGANIZATION_CODE
FROM
MTL_ITEM_REVISIONS_VL MIR
, MTL_PARAMETERS MP
, MTL_SYSTEM_ITEMS_VL MSI
WHERE
MSI.CONCATENATED_SEGMENTS = p_Item_Number
AND MP.ORGANIZATION_CODE = p_Org_Code
AND MP.ORGANIZATION_ID = MIR.ORGANIZATION_ID
AND MIR.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND MIR.ORGANIZATION_ID = MSI.ORGANIZATION_ID ORDER BY EFFECTIVITY_DATE, REVISION DESC;
Can anyone explain the extreme difference in performance between these two queries?
Thanks & Regards
CarolinThey don't look logically equivalent to me.
Here are the differences:
WHERE (MIR.INVENTORY_ITEM_ID = p_Item_ID
OR MSI.CONCATENATED_SEGMENTS = p_Item_Number)
AND (MIR.ORGANIZATION_ID = p_Org_ID
OR MP.ORGANIZATION_CODE = p_Org_Code)
vs
WHERE MSI.CONCATENATED_SEGMENTS = p_Item_Number
AND MP.ORGANIZATION_CODE = p_Org_CodeIf they aren't logically equivalent there's no point in comparing the performance. -
Hi There,
We have a table in Database with Columns ( Installed, Removed, Transaction Date ) , that table tracks the Parts when it is installed in store and when that part was removed from store with Transaction Dates
So from below example how to get the "Part A" install and Removal Dates ?
Please Help !!
Thanks,
Learning Bee !!
Dotnet.ExplorerPlease try this code:
IF OBJECT_ID('dbo.Track') IS NOT NULL
DROP TABLE dbo.Track;
GO
CREATE TABLE dbo.Track
Installed NVARCHAR(10) ,
Removed NVARCHAR(10) ,
TransactionDate INT
GO
INSERT INTO dbo.Track
( Installed, Removed, TransactionDate )
VALUES ( N'Part A', NULL, '2007' ) ,
( N'Part X', N'Part A', '2008' ) ,
( N'Part A', N'Part X', '2009' ) ,
( N'Part Y', N'Part A', '2010' ) ,
( N'Part A', N'Part Y', '2011' );
GO
WITH NewTrack
AS ( SELECT * ,
ROW_NUMBER() OVER ( ORDER BY TransactionDate ) AS Rn
FROM dbo.Track
SELECT T1.Installed AS Part ,
T1.TransactionDate AS [Installed Date] ,
T2.TransactionDate AS [Removerd Date]
FROM NewTrack AS T1
LEFT JOIN NewTrack AS T2 ON T1.Installed = T2.Removed
AND T2.Rn = T1.Rn + 1
ORDER BY Part ;
T-SQL Articles
T-SQL e-book by TechNet Wiki Community
T-SQL blog -
Custom report for TOP 10 CPU Utilization machines from any group in aggregation last seven days
I want to create a custom report that contain list of TOP CPU Utilization of machines form any group.This report is create on last 7 days CPU utilization of all machine from a group.
What should be query for this report.Hi,
Please refer to the links below:
SQL Query for TOP 10 Average CPU
https://social.technet.microsoft.com/Forums/systemcenter/en-US/8d9a2d0d-8761-4d1f-b194-b24aa65172e1/sql-query-for-top-10-average-cpu?forum=operationsmanagerreporting
How to use Report Builder to create custom reports in SCOM 2007
http://www.systemcentercentral.com/how-to-use-report-builder-to-create-custom-reports-in-scom-2007/
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]
Maybe you are looking for
-
How can I set up a second password on my teenager's iPhone
How can I set up a second password on my teenager's iPhone
-
I installed the Lion OS this weekend. After Spotlight tried to index my external hard drive (that I use to store all my data), the external hard drive died. I expected that to happen at some point. The hard drive was an old FireWire 400 LaCie that I
-
Sound output: keeps changing from internal speakers to Apple TV
My iMac keeps changing the soudn output from internal speakers to Apple TV. Why. This makes it a pain. Eveytime I use the iMAc, I have to go into preferences>sound>output and switch to internal speakers. Any ideas how to stop this form happeneing? Th
-
It is very strange for me that now in new Numbers version You can't export single sheet to PDF. Only whole document with all tables and sheets. In previous version that was very good possibility. Please write if I'm wrong. I hope that some possibilit
-
ATSServer CPU @ 200% LOCKS-UP Mac Pro dual quad-core desktop
My dual quad core running Mac OS X 10.5.5 locks-up frequently at boot. Required hard (destructive) reboot, until I figured out workaround described below. Apple really needs to fix this as a high priority. Symptom: Desktop freezes and the system beco