Query to find out last quarter data
Hi All,
I need a SQL query to find out. I have an amount field like below
Period | Amt | Amt2
====================
Jul | 0 | 0+20+30
Aug | 20 | 0
Sep | 30 | 0
Oct | 0 | 0+50
Nov | 50 |
My need is Amt2 which needs to calculating in Qtr wise. Can any one post me a query for this.
Thanks,
Kamal
Hi Valli,
Thanks, so we need to create a function and then call that from report. I have doubt in this, for example if the user enter 'SEP-12' then it will find which QTR from the case statement. But if the user have account number which is available in all the months from 2010 - 2012.
So now user will give two inputs like period_name='SEP-12' and Account Number=101010 then it should give output like sum(Q3) in the year of 2012. Here how it will calculate year wise? or do we need to specify any condition here?
Please advice,
Thanks,
Kamal
Similar Messages
-
How to find out last update date for business partner's marketing attribute
How to find out last update date for business partner's marketing attribute??
Im freshie for SAP Application and im assigned to find out last update date for marketing attribute changed
which table is involved??
Yours kindness will be appreciated
thanksYou can take a look at table AUSP as well as CRMD_AUSP_HIST.
The "changed by" and "changed at" are logged on attribute level, not on attribute value level. When you change one specific value, the system does a "re-insert" of all existing values of this attribute.
Take a look at the SAP notes 938426 and 966670 these may assit you in resolving the issue.
Regards,
William Laverde -
SQL query to find out last login for each database
Hi everybody,
I have a view with following columns:
DatabaseSid, lastLogin, firstLogin.
I want to now the newest last_login date for every database.
SID First Login Last Login
e.g. Database1, 11.11.2011, 01.12.2011
Database1, 01.04.2012, 01.05.2012
Database3, 03.03.2004, 03.06.2005
Database 3 07.09.2012, 12.10.2012
How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
Thank you in advance
SteveSteve wrote:
Hi everybody,
I have a view with following columns:
DatabaseSid, lastLogin, firstLogin.
I want to now the newest last_login date for every database.
SID First Login Last Login
e.g. Database1, 11.11.2011, 01.12.2011
Database1, 01.04.2012, 01.05.2012
Database3, 03.03.2004, 03.06.2005
Database 3 07.09.2012, 12.10.2012
How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
Thank you in advance
SteveI'm curious as to how you collect this information from multiple databases into one database, and of what value the data is once you have it. -
Sql query to find out last update of 6 hours
i have table emp . for Exp.
create table emp
(empno number(5),
ename varchar2(20),
last_update date );
Now i want the all data which is update in last 6 hoursAssuming an INDEX, WHERE Last_Update > SysDate - 6/24; is better and clearer.
It is better because it allows INDEX use. That is because it does not manipulate the COLUMN value.
It is clearer because it clearly states what we want, the records where Last_Update is after a value of six hours before. In the other query, we are checking for records where Last_Updated minus six hours is after current time. Personally, I find that harder to follow.
SQL> CREATE TABLE Emp(EmpNo NUMBER(5), EName VARCHAR(20), Last_Update DATE);
Table created.
SQL> CREATE INDEX Emp_Last_Update ON Emp(Last_Update);
Index created.
SQL> INSERT INTO Emp(Empno, EName, Last_Update) SELECT 626, 'user626892', SysDate - Level FROM Dual CONNECT BY Level <= 10000;
10000 rows created.
SQL> exec DBMS_STATS.Gather_Schema_Stats(NULL);
PL/SQL procedure successfully completed.
SQL> EXPLAIN PLAN FOR SELECT * FROM Emp WHERE SysDate - Last_Update <= 6/24;
Explained.
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 500 | 11500 | 15 (14)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 500 | 11500 | 15 (14)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(SYSDATE@!-"LAST_UPDATE"<=.25)
13 rows selected.
SQL> EXPLAIN PLAN FOR SELECT * FROM Emp WHERE Last_Update > SysDate - 6/24;
Explained.
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 38459689
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 23 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 23 | 3 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | EMP_LAST_UPDATE | 1 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("LAST_UPDATE">SYSDATE@!-.25)
14 rows selected. -
How to find out last month's 1st & last date
could you please tell me how can I find out last month's 1st & last date?
regardsHere is one way:
SQL> SELECT ADD_MONTHS
2 ( TRUNC(SYSDATE,'MONTH')
3 , -1
4 ) AS FIRST_OF_MONTH
5 , TRUNC(SYSDATE,'MONTH') - 1 AS LAST_OF_MONTH
6 FROM DUAL
7 /
FIRST_OF_MONTH LAST_OF_MONTH
05/01/2010 00:00:00 05/31/2010 00:00:00 -
Query to find out the time used by an user for an application
Hello All,
I want to know the query to find out the whole time used by the user for an application. Please view the below data
Employee:
SNO EMP_ID EMP_NAME EMP_DATE LOGIN_TIME LOGOUT_TIME
1 10 Visu 21-Nov-2010 06:30:00 07:30:00
2 10 Visu 21-Nov-2010 06:40:00 07:20:00
3 10 Visu 21-Nov-2010 06:50:00 07:50:00
4 10 Visu 21-Nov-2010 07:30:00 08:30:00
5 10 Visu 21-Nov-2010 09:30:00 10:30:00
By checking the above data we can say that the total time Visu used the application is
8.30 - 6.30 (From 1,2,3,4 records) = 2hrs
10.30 - 9.30 (Based on 5th rec) = 1hr
So the total time Visu used the application would be 3 hrs = 180 mins.
Could you please help me in getting the result from that data using a query?odie_63 wrote:
I think it may be solved with analytics too.
with t1 as (
select 1 sno,10 emp_id,'Visu' emp_name,'21-Nov-2010' emp_date,'06:30:00' login_time,'07:30:00' logout_time from dual union all
select 2,10,'Visu','21-Nov-2010','06:40:00','07:20:00' from dual union all
select 3,10,'Visu','21-Nov-2010','06:50:00','07:50:00' from dual union all
select 4,10,'Visu','21-Nov-2010','07:30:00','08:30:00' from dual union all
select 5,10,'Visu','21-Nov-2010','09:30:00','10:30:00' from dual
t2 as (
select emp_id,
emp_name,
emp_date,
to_date(emp_date || login_time,'DD-MON-YYYYHH24:MI:SS') login_time,
to_date(emp_date || logout_time,'DD-MON-YYYYHH24:MI:SS') logout_time
from t1
t3 as (
select t2.*,
case
when login_time < max(logout_time) over(
partition by emp_id,emp_date
order by login_time
rows between unbounded preceding
and 1 preceding
then 0
else 1
end start_of_group
from t2
t4 as (
select t3.*,
sum(start_of_group) over(partition by emp_id,emp_date order by login_time) grp
from t3
t5 as (
select emp_id,
emp_date,
min(login_time) login_time,
max(logout_time) logout_time
from t4
group by emp_id,
emp_date,
grp
select emp_id,
numtodsinterval(sum(logout_time - login_time),'day') time_spent
from t5
group by emp_id
order by emp_id
EMP_ID TIME_SPENT
10 +000000000 03:00:00.000000000
SQL> SY. -
How to find out the Hire date of an employee?
Hi All
What is effective date, Latest start date and other date fields which are are used when we create a new employee?
What is the difference between hire date and joining date?
How to find out the Hire date and joining date of an employee?
Regards
RahmanThe effective dates are related to date tracking. The effective start date shows when this version of the record became effective.
The Hire Date, or Latest Satrt Date shows the date on which the employee was last hired. If he was hired before from 01/01/01 to 31/12/01, then left but was hired again from 01/01/07, the Latest Hired Date would be 01/01/07 and the First Hired Date would be 01/01/01.
When using Oracle HR, datetracking allows you to either correct data (because it was wrong or incomplete), or update it (because a time effective change took place e.g. got married).
The[b] effective dates show when a record was updated. So, if an update was made on 07/02/07, and the update datetrack option was used, the current record would have its effective end date set to 06/02/07 (the day before the update) and a new version would be created with the updates and an effective start date of 07/02/07.
Hope this helps. -
How to find out the Release date & Release code of PO's ?
Dear All,
Is there any standard reports available to find out the Release date & Release codes of PO's which are already released & the PO's which are pending for release ?
Regards,HI All,
Thanks a lot for your response.
In ME2N,ME2M etc..I have to select each single PO line item & then have to go to Header Changes to find out this info.
So, Is it possible to find out the release codes/release date of all the PO's in a single shot?
Hope my query is clear.
Thanks & Regards, -
Need query to find out the sum till a period
Hi,
I need to write one query to find out the cumulative sum of raw_cost of table pa_budget_lines till the specified period, I tried to do this by analytical function, but that is not working in Report 10g. Can anybody help me in this.
Thanksnot familiar with report but could you do something like this
with t as
select 1 grp, 10 * level the_cost, add_months (sysdate, level) effective_dt from dual connect by level < 11 union all
select 2 grp, 5 * level the_cost, add_months (sysdate, level) effective_dt from dual connect by level < 11
input as
( select null grp, null the_cost, null running_total, v_eff_dt effective_dt from dual)
select * from(
select t.grp, t.the_cost, sum(t.the_cost) over (partition by t.grp order by t.effective_dt) running_total, t.effective_dt,
lead(t.effective_dt) over (partition by t.grp order by t.effective_dt) next_effective_dt,
input.effective_dt inp_eff_dt
from t, input
where inp_eff_dt between effective_dt and next_effective_dtv_eff_dt would be the input date you are interested in -
Query to find out the Activities done against a table
Hi,
One table has been truncated and data reloaded into the table by the user. But at latter stage user deny that activity. I believe all these activities stored in any oracle 10g database table.
Need a query to find out the activities done on a specific date say 6th Sep.
This is too urgent. Thanks in advanceHi,
Welcome to the forum!
If you don't have enable table auditing maybe you can see last_ddl_time column of user_objects view:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> select * from test2;
COL1 COL2 COL3
1 1 3
1 2 3
1 3 3
SQL> select to_char(uo.created, 'DD/MM/YYYY HH24:MI:SS'), to_char(uo.last_ddl_time, 'DD/MM/YYYY HH24:MI:SS') from user_objects uo where uo.object_name = 'TEST2';
TO_CHAR(UO.CREATED,'DD/MM/YYYY TO_CHAR(UO.LAST_DDL_TIME,'DD/M
12/09/2009 12:20:26 12/09/2009 12:20:27
SQL> truncate table test2;
Table truncated
SQL> select to_char(uo.created, 'DD/MM/YYYY HH24:MI:SS'), to_char(uo.last_ddl_time, 'DD/MM/YYYY HH24:MI:SS') from user_objects uo where uo.object_name = 'TEST2';
TO_CHAR(UO.CREATED,'DD/MM/YYYY TO_CHAR(UO.LAST_DDL_TIME,'DD/M
12/09/2009 12:20:26 12/09/2009 14:01:21
SQL> Regards, -
How to find the last update date time and user of record field peoplecode
how to find the last update date time record field peoplecode?
Thank you.One can check the last update date time using the following query
SELECT LASTUPDDTTM FROM PSPCMPROG WHERE OBJECTVALUE1 LIKE 'RECNAME' AND OBJECTVALUE2 LIKE 'FIELDNAME' -
SQL Query to Find out User has what all resources provisioned !
Hi Guys ,
Does any one have a SQL query to find out what resources are provisioned to a particular user ?
Thanks
SurenHi,
Hope this will help you.
SELECT distinct usr_login as "IdM User ID",
usr_employeeID as "Employee ID",
usr.USR_FIRST_NAME as "First Name",
usr.USR_LAST_NAME as "Last Name",
usr_status
as "User Status",
USR_EMP_TYPE as "Employee Type",
obj.obj_name as "Application Resource",
ost_status as "Application Resource Status",
FROM ost,oiu,obj,usr,obi
WHERE oiu.ost_key = ost.ost_key AND obj.obj_key = obi.obj_key AND oiu.usr_key = usr.usr_key
AND ost_status in ('Provisioned','Revoked','Disabled', 'Provisioning')
AND oiu.obi_key=obi.obi_key
AND usr_EmployeeID like '11111'
This query will provide all the resources to which the user is linked with and the resource status is in 'Provisioned','Revoked','Disabled', 'Provisioning' status for a particular employeed ID, I am not completely sure whether I have given the Employee ID column from USR table as correct or not. Verify once and query the DB -
Writing a query to find out who is having a given responsibility name.
Hi,
I am new to Oracle Apps and have no idea about its tables. Can anyone please help me in writing a query to find out who is having a given responsibility name.
Thanks in advance.
Regards
HimanshuHi
you can get required data by using this query
select usr.user_name
, res.responsibility_name
from fnd_user usr
, FND_USER_RESP_GROUPS_DIRECT usrrep
, fnd_responsibility_tl res
where usr.user_id=usrrep.user_id
and usrrep.responsibility_id=res.RESPONSIBILITY_ID
group by usr.user_name,res.responsibility_name
Regards,
Venky -
Script to pull out last logon date
Hello,
I have a list of user that I would like to pull out last logon date from AD.
This is the script I am using at the moment but it produces blanks and I don't know what the blanks mean.
Import-Module ActiveDirectory
#This script requires PowerShell AD Module
Import-csv "c:\scripts\samaccountname.csv" |
foreach-object {get-aduser $_.samaccountname -Properties lastlogondate} |
select name,Lastlogondate |
Export-csv c:\scripts\LastLogon.csv -NoTypeInformation
Please can you help?
Kind Regards, PenDraKonIf you want an accurate lastLogon date, you have to check across domain controllers.
Here's an advanced function I created a while ago for this.
Function Get-LastLogon {
<#
.SYNOPSIS
Returns LastLogon information
.DESCRIPTION
Queries the LastLogin information for a user across domain controllers and returns the highest (latest) value
.EXAMPLE
Get-LastLogon User
.EXAMPLE
Get-LastLogon -Identity User
.EXAMPLE
Get-ADUser User | Get-LastLogon
.EXAMPLE
Get-LastLogon User1, User2
.PARAMETER users
List of users - pipeline can be used
#>
[CmdletBinding()]
param
[Parameter(Position= 0,
Mandatory=$True,
ValueFromPipeline=$True,
HelpMessage='What user would you like to find the last logon for?')]
$identity
Begin {}
Process {
Foreach ($account in $identity) {
$dateStamp = $null
$domainController =$null
Get-ADDomainController -Filter * | Foreach {
$dc = $_.HostName
$lastLogon = (Get-ADUser $account -Properties LastLogon -server $dc | Select-Object Name,@{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}}).Lastlogon
If ($dateStamp -le $lastlogon)
$dateStamp = $lastlogon
$domainController = $dc
} # End of ForEach
$properties = @{
Name=$account;
LastLogon=$dateStamp;
DomainController=$domainController}
New-Object -TypeName PSObject -Prop $properties
} # End of ForEach
} # End of Process
End {}
} # End of Function
You can then run...
Import-CSV ".\samaccountname.csv" | % {Get-LastLogon $_.samaccountname}
or...
Import-CSV ".\samaccountname.csv" | % {Get-LastLogon $_.samaccountname} | Export-CSV ".\report.csv" -noType -
How to use ONE query to find out tree structure?
ID------------upperID----------Name------------------------isFolder
1------------ 0---------- Folder
1------------------------------------1
2------------ 1------------ Folder 1- Sub
Folder--------------------1
3------------ 2------------
Folder1-Item1-A--------------------------0
4------------ 1------------ Folder 1- Sub
Item-----------------------0
Hi all, if I have a table like above to demonstrate the
folders and item relationship. This structure allows the user to
create unlimited folders and items.
Now I would like to use one query to find out the tree
structure of this table, how could I do the query.
Any help on this will be highly appreciated!
Thanks,
ezAlso, see this thread:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=12 55788&enterthread=y
Maybe you are looking for
-
Hello. I have Toshiba 39L4353RB with latest aviable f/w 7.1.56.36.01.1 for this model. There are not options for TimeShift and Recording in Menu. I have selected country Germany, DVB-C with CAM-module (digital TV). I have insert USB HDD, but there wa
-
Since OES 11 SP2 computer members of groups are not shown in AD Users and Computers mmc snapin
I have several groups of computers in my DSfW Domain, They are mainly used to apply different GPOs to different groups. If you look via iManager or C1 at the properties of the groups you see the computers, which are members of the groups on the membe
-
What the "binaural" stuff is used for???
hey, I'm starting in mixing techniques and I noticed that I had a "binaural" in the mixer. what it is used for??
-
I have master detail setup real similar to a department employee setup. I'll use that as my example for simplicity. From the master page, user can select a button which will bring them to the associated detail row(s) page. There, the user can edit, c
-
I've had this issue today aswell, I try to log in to my e-mail and it keeps saying my password is wrong then when I try to reset my password it says my account is suspended. I haven't done anything in my e-mails for days so I don't see why it should