Query to find the maximum and second maximum
i have a table temptab of 3 columns
col1 col2 col3
1 a 08-JAN-08
1 a 09-JAN-08
1 a 10-JAN-08
1 b 10-JAN-08
1 c 11-mar-08
1 c 10-mar-08
i want to select 1st maxm and 2nd maxm of col3 group by (col1,col2)
o/p will be like
1 a 10-jan-08 08-jan-08
1 b 10-jan-08 null
1 c 11-mar-08 10-mar-08
select first.col1, first.col2, first.MAX_DATE, second.SEC_DATE from (select a.col1, a.col2, max(a.col3) as MAX_DATE
from tab1 a group by a.col1, a.col2) first,
(select b.col1, b.col2, max(b.col3) as SEC_DATE from tab1 b,
(select a.col1, a.col2, max(a.col3) as MAX_DATE from tab1 a
group by a.col1, a.col2) c
WHERE c.col1 = b.col1
AND c.col1=b.col1
AND c.MAX_DATE > b.col3
group by b.col1, b.col2) second
where first.col1 = second.col1
and first.col2 = second.col2;
this is not working..
please give a query which will do this.
1. Your query have 3 subqueries where mine only one. Feel free to make your choice regarding the performance.
2. You cannot have a column named date, unless you use double-quotes
3. Your query doesn't work as well when you have not any second highest value
4. Your query return a cartesian product of your table.
Please check the results of your query (after applying the required modications) with the mine above, and make your choice :
SQL> with tbl as
2 (select 1 col1, 'a' col2, to_date('08-JAN-08','DD-MON-YY') col3 from dual union all
3 select 1 col1, 'a' col2, to_date('09-JAN-08','DD-MON-YY') col3 from dual union all
4 select 1 col1, 'a' col2, to_date('10-JAN-08','DD-MON-YY') col3 from dual union all
5 select 1 col1, 'b' col2, to_date('10-JAN-08','DD-MON-YY') col3 from dual union all
6 select 1 col1, 'c' col2, to_date('11-mar-08','DD-MON-YY') col3 from dual union all
7 select 1 col1, 'c' col2, to_date('10-mar-08','DD-MON-YY') col3 from dual )
8 --end of data sample
9 select t1.col1 ,t1.col2 ,t1.col3,t2.col3
10 from (select col1,col2,max(col3) col3
11 from tbl
12 group by col1,col2 ) t1,
13 (select col1, col2, col3
14 from (select col1, col2, col3,
15 row_number() over (partition by col1, col2 order by col3 desc) rn
16 from tbl)
17 where rn <= 2) t2
18 where t1.col3 !=t2.col3;
COL1 C COL3 COL3
1 c 11-MAR-08 10-JAN-08
1 a 10-JAN-08 09-JAN-08
1 b 10-JAN-08 09-JAN-08[i] <-- obviously wrong, there is no 09-JAN-08 for 1b
1 c 11-MAR-08 09-JAN-08[i] <-- obviously wrong, there is no 09-JAN-08 for 1c
1 c 11-MAR-08 10-JAN-08[i] <-- obviously wrong, there is no 10-JAN-08 for 1c
1 a 10-JAN-08 11-MAR-08[i] <-- obviously wrong, there is no 11-MAR-08 for 1a
1 b 10-JAN-08 11-MAR-08[i] <-- obviously wrong, there is no 11-MAR-08 for 1b
1 a 10-JAN-08 10-MAR-08[i] <-- obviously wrong, there is no 10-MAR-08 for 1a
1 b 10-JAN-08 10-MAR-08[i] <-- obviously wrong, there is no 10-MAR-08 for 1b
1 c 11-MAR-08 10-MAR-08[i] <-- obviously wrong, duplicate row
10 rows selected.Nicolas.
Similar Messages
-
Query to find the Views and synonyms that are accessing through db_link
HI all,
Oracle 10g
I need a Query to find the Views and synonyms that are accessing through db_link.
ie.
database A have the db_link to database B through a schema A
now i need to find what are the Synonyms and views that are accessing through db_link either directly or indirectly..
regards,
Deepak
Edited by: Deepak_DBA on Dec 10, 2010 5:38 PMOn the second database (B) use this query to find the SQL which used by the schema A (DB LINK USER). Check the SQL_FULLTEXT column.
select sql_fulltext,sql_id,module,parsing_schema_name,parsing_user_id,first_load_time,loads,users_executing,rows_processed,plsql_exec_time,sorts,fetches,invalidations,parse_calls,cpu_time,elapsed_time,disk_reads,buffer_gets
from V$sqlarea
where parsing_schema_name = 'A' --and to_char(first_load_time,'dd/mm/yyyy') like '%11/08/2007'
order by first_load_time desc;
Regards
Asif Kabir -
Query to find the start and end date of current quarter
I want a query to give me the start date and end date of current quarter
I don't want to use TRUNC and ROUND as the 16th day roundoff logic is not required.
Thanks in advance.Hi ,
I'm quite sure that the year quarters are static.....
So , you can save them as records of a table , such as:
QRTY START_DAY END DAY
============================
1 1/1 30/3
2 1/4 30/6
3 1/7 30/9
4 1/10 31/12
The sysdate(day of the current quarter) must be between a start_day and appropriate end_day of the quarters, concatenated with the sysyear (year of the sysdate).
So , if the above table is called Quarters ...
then
select start_day , end_day
from quarters
where to_date(sysdate,'dd/mm/rrrr') between (to_date(trim((start_day||'/'||to_char(sysdate,'rrrr'))),'dd/mm/rrrr'))
and (to_date(trim((end_day||'/'||to_char(sysdate,'rrrr'))),'dd/mm/rrrr'));
[b]Result
START_DAY END_DAY
1/10 31/12
Regards,
Simon
Message was edited by:
sgalaxy
Message was edited by:
sgalaxy -
Query to find the second maximum date in a table
please give me the query to find the second maximum date in a table
You can try with this
SELECT empno
,hiredate
FROM emp a
WHERE 2 = (SELECT COUNT(DISTINCT hiredate)
FROM emp b
WHERE b.hiredate >= a.hiredate
OR
SELECT empno
,hiredate
FROM (SELECT ROWNUM row_num
,empno
,hiredate
FROM emp a
ORDER BY hiredate ASC
WHERE row_num = 2;Regards
Arun -
Query to find the class name that has the maximum number of students ?
I need the query to find the [class Name] which has the most number of students. please look below at the tables
Students Table
StudentId StudentName ClassID
1 xxx 1
2 yyy 1
3 zzz 1
4 fff 2
5 ttt 2
Classes Table
ClassID ClassNane
1 CSHARP
2 JSHARP
The result should be : CSHARP
since there are 3 students in CSHARP and 2 students in JSHARP class
Appreciate your help
ThanksTry:
DECLARE @Classes TABLE (
ClassID INT identity(1, 1) PRIMARY KEY
,ClassName VARCHAR(50)
INSERT INTO @Classes (ClassName)
VALUES ('CSharp')
,('JSharp')
DECLARE @Students TABLE (
StudentID INT identity(1, 1) PRIMARY KEY
,StudentName VARCHAR(10)
,ClassID INT
INSERT INTO @Students (
StudentName
,ClassID
VALUES (
'xxx'
,1
'yyy'
,1
'zzz'
,1
'fff'
,2
'ttt'
,2
SELECT TOP (1)
WITH TIES C.ClassName
FROM @Classes C
INNER JOIN @Students S ON C.ClassID = S.ClassID
GROUP BY C.ClassID
,C.ClassName
ORDER BY COUNT(S.StudentID) DESC
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
How to find the sessions which generated maximum redo amount at instance?
I use below query or Sql*Plus's set autotrace traceonly statistics > redo size statistic to calculate how much redo I generated in my session;
CREATE OR REPLACE VIEW redo_size AS
SELECT value
FROM v$mystat, v$statname
WHERE v$mystat.statistic# = v$statname.statistic#
AND v$statname.name = ‘redo size’;
But how to find the sessions which generated maximum(top 5 for example) redo from the last database startup on 9iR2 or also with new 10gR2 historic views?
We need this information because from the produced archived log files we observe something new producing almost 2 times more redo for a week. I looked at statspack report but couldnt find as I suspected for a massive update or delete.
Best regards,
TongucI tried v$sysstat but I didnt think about v$sesstat Mr.Gasparotto, thank you very much :)
SELECT ss.sid,
sq.sql_text,
se.status,
se.username,
se.osuser,
se.program,
se.machine,
ss.VALUE
FROM v$sesstat ss, v$statname sn, v$session se, v$sqlarea sq
WHERE ss.statistic# = sn.statistic#
AND se.sql_hash_value = sq.hash_value(+)
AND se.sql_address = sq.address(+)
AND ss.sid = se.sid
AND sn.NAME = 'redo size'
ORDER BY ss.VALUE DESC
Best regards. -
Query to find the list of users having access to a particular scenario
Hi,
I am learning Hyperion Planning 9.2 x version. I wanted to know the query to find the list of users having access to Plan Iteration - 1 scenarion.
As I am new to Hyperion Essbase and Hyperion Planning, I am assuming these ideas work out to get the desired result.
1) As Hyperion Planning uses Relational DB to store the User Security information, we can query the list of users who is having access to Plan Iteration - 1 Scenario.
I am not sure if this solution works. Please correct me If I am wrong.
2) We can also query from the essbase editor to find out who all having access to this scenario.
If the above is correct, can you please provide me the query.
I am really need of this and I will be happy if any one provide the solution.
Thanks & Regards,
Upendra. BesthaHi,
If you are looking for some SQL to retrieve the access rights by member then you can use something like (SQL Server code though can easily be modified for Oracle)
SELECT usr.object_name as Username,mem.object_name as Member,
'Access Rights' = CASE acc.access_mode
WHEN -1 THEN 'None'
WHEN 1 THEN 'Read'
WHEN 2 THEN 'Write'
WHEN 3 THEN 'Write'
ELSE 'Unknown' END,
'Relation' = CASE acc.flags
WHEN 0 THEN 'Member'
WHEN 5 THEN 'Children'
WHEN 6 THEN 'Children (inclusive)'
WHEN 8 THEN 'Descendants'
WHEN 9 THEN 'Descendants (inclusive)'
ELSE 'Unknown' END
FROM
hsp_access_control acc, hsp_object mem, hsp_object usr
WHERE acc.object_id = mem.object_id
AND acc.user_id = usr.object_id
AND mem.object_name = 'Plan Iteration - 1'
Cheers
John
http://john-goodwin.blogspot.com/ -
How to find the Date and Time of Modification of Column in aTable?
Hi all,
Do you know how to find the Date and Time of Addition of Column to a Particular Table?.
I know however, How to find the modification time of the Table. Using the below Query :
Select Object_Name, to_Char(Last_DDL_TIME, 'DD-Mon-YYYY HH24:MI:SS') Last_DDL from User_Objects where Object_Type = 'TABLE';
Object_Name
Last_DDL
Employee
20-Aug-2013 09:23:03
I wanted to know the Creation or Modification Date and Timestamp of all columns of Employee Table?. Is it possible at all. If possible, How to get it?.
Regards,
Bhaskar MI agree with you on that. Since its a development enviornment I can remove the column but that not my point here.
My whole purpose it to know whether we get the Column's Creation or Modification DateTime. -
Query to find the no of columns in a table
Is there a query to find the total number of columns in a table?
Dou you know read?
-- the number of rows in a table named yourtable:
select count(1) from yourtable;
-- the number of columns in a table
-- If is a user's table:
select count(1)
from user_tab_columns
where table_name='YOURTABLE'
--If it is´t
select count(1)
from DBA_tab_columns
where owner = 'USEROWNER'
and table_name='YOURTABLE' -
How to find the job and job status from RSPCM
hi all,
suppose we got an error and in rspcm the process was failed.i want to know the status of that particular job.and if any i want to stop that job in SM37.
plz tell me how to find the job and job ststus from RSPCM...and how to stop that job in SM37
thanks,
jackHi Jack,
RSPCM: T.Code
This transaction is used to monitor the process chains
First:
here you need to add the process chains into the sheet
Second:
Then you can monitor the process chains in this transaction code
Like you can see the : status ,proces chain ,Last run date ,Last run time ,Log ID
Status : Green when sucessful,Yellow when running & Red when you get errors
Now when yoy click on any of the process chain in RSPCM you will go to the LOG VIEW as you see in RSPC transaction
SM37:T.code
This transaction is used for Job Overview
you can see many options in SM37
like Released,active,cancelled,finished,etc
Just select the ACTIVE jobs and also pass STAR in JOB ID & USER ID
here you can only see the active jobs
Goto Step in toolbar
select the program displayed
then chose option GOTO - Variant in main menu bar
in the variant you can see the job belong to which Process chain
if you want to cancel this job come back to SM37 Display screen
Select the Job and select the JOB DETAILS tab in Tool Bar
Collect the WIP ( Work Permit ID)
Go to SM50 T.code and find the WIP
in Main Menu Bar you find the option Cancel with Core choose this it will cancel the Job
Regards
Hari -
Query to track the holder and waiter info
Hi All,
I have framed the following query to get the blocker and holder info.
I intend to use this query in a auto-generated mail which executes every 15 mins
I have put an outer join on the holder because the holder DML might have completed its execution (v$sqlarea might not have info about this holder DML) at the time the auto mail configuration fires this query
I am not a dba and was apprehensive if there is some mistake in the logic of my query.
I was also expecting to join v$sql_bind_capture using sql_hash_value and sql_address just the way in which I have joined v$sqlarea
Looking forward to your kind help in vetting the below query
Select distinct waiting_session,
dba_waiters.holding_session,
decode(to_char(session_waiting_info.STATE),'0','waiter is currently waiting','-2','duration of last wait by waiter is unknown','-1','waiter waited for a short time',' waiter waited long time') "waiters waiting state",
decode(session_waiting_info.WAIT_TIME,0,'waiter waiting') "waiters last wait time",
decode(to_char(session_holding_info.STATE),'0','holder is currently waiting','-2','duration of last wait by holder is unknown','-1','holder waited for a short time','holder waited long time') "holders waiting state",
decode(session_holding_info.WAIT_TIME,0,'waiter waiting') "holders last wait time",
sql_waiting_info.sql_text "query of the waiter",
sql_holding_info.sql_text "query of the holder",
session_waiting_info.STATUS "waiting STATUS",
session_holding_info.STATUS "holding STATUS",
session_waiting_info.process "waiting process",
session_waiting_info.PROGRAM "waiting PROGRAM",
session_holding_info.process "holding process",
session_holding_info.PROGRAM "holding PROGRAM",
session_waiting_info.ROW_WAIT_OBJ# "waiting object",
session_waiting_info.ROW_WAIT_ROW# "waiting row",
session_holding_info.ROW_WAIT_OBJ# "holding object",
session_holding_info.ROW_WAIT_ROW# "holding row",
session_waiting_info.BLOCKING_SESSION_STATUS "waiting session status",
session_holding_info.BLOCKING_SESSION_STATUS "holding session status",
session_waiting_info.username "holding os username",
session_holding_info.username "waiting os username",
session_waiting_info.MACHINE "waiting MACHINE",
session_waiting_info.TERMINAL "waiting TERMINAL",
session_holding_info.MACHINE "holding MACHINE",
session_holding_info.TERMINAL "holding TERMINAL",
session_waiting_info.TYPE "waiting TYPE",
session_holding_info.TYPE "holding TYPE"
from dba_waiters,
v$session session_holding_info,
v$session session_waiting_info,
v$sqlarea sql_waiting_info,
v$sqlarea sql_holding_info
Where dba_waiters.waiting_Session = session_waiting_info.sid
and dba_waiters.holding_Session = session_holding_info.sid
And session_waiting_info.sql_hash_value = sql_waiting_info.hash_value
And session_waiting_info.sql_address = sql_waiting_info.address
and session_holding_info.sql_hash_value = sql_holding_info.hash_value(+)
And session_holding_info.sql_address = sql_holding_info.address(+)
and dba_waiters.mode_held 'None'
Regards,
VishalHi Jonathan,
I have tried to incorporate your suggestions in the below query. Please let me know about the problems that the below query suffers from
select session_waiting_info.BLOCKING_SESSION,
waiter.sid waiting_session,
waiter.SECONDS_IN_WAIT,
decode(session_holding_info.STATE,'WAITED SHORT TIME','Holder did not wait and is currently '||session_holding_info.STATUS,'WAITING','Holder is also waiting for the past '||session_holding_info.SECONDS_IN_WAIT ||' seconds','WAITED UNKNOWN TIME','Duration of last wait of holder is unknown','WAITED KNOWN TIME','Duration of last wait by the holder is:'||session_holding_info.STATE || ' and is currently '||session_holding_info.STATUS) "State of holder",
sql_waiter_info.SQL_TEXT,
bind_values.NAME,
bind_values.VALUE_STRING,
session_waiting_info.STATUS "waiting STATUS",
session_waiting_info.username "holding os username",
session_holding_info.username "waiting os username",
session_waiting_info.STATUS "waiting STATUS",
session_waiting_info.process "waiting process",
session_holding_info.process "holding process",
session_waiting_info.PROGRAM "waiting PROGRAM",
session_holding_info.PROGRAM "holding PROGRAM",
session_waiting_info.ROW_WAIT_OBJ# "waiting object",
session_waiting_info.ROW_WAIT_ROW# "waiting row",
session_holding_info.ROW_WAIT_OBJ# "holding object",
session_holding_info.ROW_WAIT_ROW# "holding row",
session_waiting_info.sql_id,
session_waiting_info.SQL_CHILD_NUMBER
from V$SESSION_WAIT waiter,
V$SESSION session_holding_info,
V$SESSION session_waiting_info,
V$SQLSTATS sql_waiter_info,
V$SQL_BIND_CAPTURE bind_values
where waiter.sid = session_waiting_info.sid
and session_waiting_info.BLOCKING_SESSION = session_holding_info.sid
and session_waiting_info.sql_id = sql_waiter_info.sql_id
and session_waiting_info.sql_id = bind_values.sql_id(+)
and session_waiting_info.SQL_CHILD_NUMBER = bind_values.CHILD_NUMBER(+)
and waiter.WAIT_TIME = 0
Regrds,
Vishal -
Query to get the blocker and holder info
Hi All,
I have framed the following query to get the blocker and holder info.I intend to use this query in a auto-generated mail which executes every 15 mins
I have put an outer join on the holder because the holder query might have been executed at the time the auto mail configuration fires this query
I am not a dba and was apprehensive is there is some mistake in the logic of my query. I was also expecting to join v$sql_bind_capture using sql_hash_value and sql_address just the way in which I have joined v$sqlarea
Looking forward to your kind help in vetting the below query
Select distinct waiting_session,
dba_waiters.holding_session,
decode(to_char(session_waiting_info.STATE),'0','waiter is currently waiting','-2','duration of last wait by waiter is unknown','-1','waiter waited for a short time',' waiter waited long time') "waiters waiting state",
decode(session_waiting_info.WAIT_TIME,0,'waiter waiting') "waiters last wait time",
decode(to_char(session_holding_info.STATE),'0','holder is currently waiting','-2','duration of last wait by holder is unknown','-1','holder waited for a short time','holder waited long time') "holders waiting state",
decode(session_holding_info.WAIT_TIME,0,'waiter waiting') "holders last wait time",
sql_waiting_info.sql_text "query of the waiter",
sql_holding_info.sql_text "query of the holder",
session_waiting_info.STATUS "waiting STATUS",
session_holding_info.STATUS "holding STATUS",
session_waiting_info.process "waiting process",
session_waiting_info.PROGRAM "waiting PROGRAM",
session_holding_info.process "holding process",
session_holding_info.PROGRAM "holding PROGRAM",
session_waiting_info.ROW_WAIT_OBJ# "waiting object",
session_waiting_info.ROW_WAIT_ROW# "waiting row",
session_holding_info.ROW_WAIT_OBJ# "holding object",
session_holding_info.ROW_WAIT_ROW# "holding row",
session_waiting_info.BLOCKING_SESSION_STATUS "waiting session status",
session_holding_info.BLOCKING_SESSION_STATUS "holding session status",
session_waiting_info.username "holding os username",
session_holding_info.username "waiting os username",
session_waiting_info.MACHINE "waiting MACHINE",
session_waiting_info.TERMINAL "waiting TERMINAL",
session_holding_info.MACHINE "holding MACHINE",
session_holding_info.TERMINAL "holding TERMINAL",
session_waiting_info.TYPE "waiting TYPE",
session_holding_info.TYPE "holding TYPE"
from dba_waiters,
v$session session_holding_info,
v$session session_waiting_info,
v$sqlarea sql_waiting_info,
v$sqlarea sql_holding_info
Where dba_waiters.waiting_Session = session_waiting_info.sid
and dba_waiters.holding_Session = session_holding_info.sid
And session_waiting_info.sql_hash_value = sql_waiting_info.hash_value
And session_waiting_info.sql_address = sql_waiting_info.address
and session_holding_info.sql_hash_value = sql_holding_info.hash_value(+)
And session_holding_info.sql_address = sql_holding_info.address(+)
and dba_waiters.mode_held <> 'None'
Regards,
Vishal
Edited by: user11924113 on Feb 18, 2011 2:39 AMQuery to track the holder and waiter info
People who reach this place for a similar problem can use the above link to find their answer
Regards,
Vishal -
Query to find the latest record with respect to the current status
Dear gurus
I have the following data in a table
Customernum
bkcode
reqtdate
Prevstat
currstat
The data will be like this
CustomerNum bkcode reqdate prevstat currstat
5900 1 03-Aug-12 0 1
5900 1 06-Aug-12 1 0
5900 5 22-Jun-12 0 1
If a customer has an issue to solved, a record is added with bkcode , register date and currstat will be 1
If the issue is resolved for the bookingcode,a new record is added, the currentstatus will become 0. and prev stat will show 1. Row no 1 and 2 reflects this case
If this table is queried for finding the unresolved issues. the output should be only the Last row of the above example. since issue with bookingcode 1 has been resolved
I have trying hard to get this thing confused what to use Lead or Max
Kindly guide meHi,
one way here:
WITH mytable(CustomerNum, bkcode, reqdate, prevstat, currstat)
AS
SELECT 5900, 1, TO_DATE('03-Aug-12', 'DD-Mon-YY'), 0, 1 FROM DUAL UNION ALL
SELECT 5900, 1, TO_DATE('06-Aug-12', 'DD-Mon-YY'), 1, 0 FROM DUAL UNION ALL
SELECT 5900, 5, TO_DATE('22-Jun-12', 'DD-Mon-YY'), 0, 1 FROM DUAL
SELECT CustomerNum, bkcode, reqdate, prevstat, currstat
FROM (SELECT a.*
, ROW_NUMBER() OVER (PARTITION BY CustomerNum, bkcode
ORDER BY reqdate DESC) AS rn
FROM mytable a
WHERE rn=1
AND currstat=1;
CUSTOMERNUM BKCODE REQDATE PREVSTAT CURRSTAT
5900 5 22-JUN-12 0 1Regards.
Al
Edited by: Alberto Faenza on Dec 18, 2012 5:23 PM
Changed again!! Previous logic was wrong -
Query to find the Salary table details HRMS 11i
I am looking query to find the persons salary details in Oralce EBS 11i.
I tried the below query bu it didn'ty work.
SELECT papf.employee_number
,papf.full_name
,pj.NAME job
,haou.NAME ORGANIZATION
,ppp.proposed_salary_n salary
FROM per_all_people_f papf
,per_all_assignments_f paaf
,per_jobs pj
,hr_all_organization_units haou
,per_position_definitions ppd
,per_all_positions pap
,per_pay_proposals ppp
WHERE 1 = 1
AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date
AND papf.current_employee_flag = 'Y'
AND papf.employee_number IS NOT NULL
AND paaf.person_id = papf.person_id
AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND paaf.job_id = pj.job_id
AND paaf.organization_id = haou.organization_id
AND paaf.position_id = pap.position_id
AND pap.position_definition_id = ppd.position_definition_id
AND ppp.pay_proposal_id = (SELECT MAX (pay_proposal_id)
FROM per_pay_proposals
WHERE assignment_id = paaf.assignment_id)
In our case all the below tables have 0 records..
select count(*) from PER_PAY_PROPOSALS ;
COUNT(*)
0
select count(*) from pay_element_entry_values_f;
COUNT(*)
0
select count(*) from PAY_ELEMENT_ENTRY_VALUES_F;
COUNT(*)
0
select count(*) from PAY_ELEMENT_ENTRIES_F;
COUNT(*)
0Hi,
Your results clearly states that there is no salary data which is been captured as well as there are no element entries which are assigned to any assignment.
Please do the below which will insert records in salary as well as element entries table:
1. Add a salary proposal to any active employee (People Enter and Maination --> Search for any employee --> Assignment --> Salary) - This will insert a record in PER_PAY_PROPOSALS table
2. Add an element entry to any active assignment (People Enter and Maination --> Search for any employee --> Assignment --> Entries) - This will insert a record in PAY_ELEMENT_ENTRIES_F and PAY_ELEMENT_ENTRY_VALUES_F table
Hope this clarifies.
Thanks,
Sanjay -
SQL Query to find the Delta between 2 rows
Can the below be possible? If so can you help me writing aSQL Query to do so…
I have data in spreadsheet which is pulled off from the database (data from more than one table with joins); send it to the different teams. They will check the data n update the spreadsheet if necessary and send it back to me.
I have to find the changes and update the database from the provided spreadsheet accordingly. Changes can be on different columns on each set of row.
Example:
DataFrom
ServerName
Branch_Name
Application_Name
Server Status
Application_Status
App_Environment
Tier
SQL Query
abcdef
app
adp
Deployed
Deployed
Production
silver
Excel
abcdef
app
adp
Deployed
Deployed
Development
Bronze
DataFrom
ServerName
Branch_Name
Application_Name
Server Status
Application_Status
App_Environment
Tier
SQL Query
Hijkl
app
adp
Deployed
Deployed
Production
Gold
Excel
Hijkl
app
Dep
Deployed
Deployed
Production
Gold
DataFrom
ServerName
Branch_Name
Application_Name
Server Status
Application_Status
App_Environment
Tier
SQL Query
Xzy
app
Dep
Deployed
Deployed
Production
Silver
Excel
Xzy
App
Dep
Deployed
Deployed
Development
Silver
Above scenario is an example what I am look to do with sql script? Opinions/queries accepted…
There are 1200+ rows to compare it manually which is a pain.
Thanks.Columns are different, when the contain multiple distinct values.
SELECT COUNT(DISTINCT Name) ,
COUNT(DISTINCT GroupName) ,
COUNT(*)
FROM HumanResources.Department;
Without a concise and complete example (table DDL and sample data insert statements), it's hard to tell what the correct solution could be..
DECLARE @Sample TABLE ( SetID INT, ServerID INT, ApplicationID INT );
INSERT INTO @Sample
VALUES ( 1, 1, 1 ),
( 1, 1, 1 ),
( 2, 1, 1 ),
( 2, 1, 2 ),
( 3, 1, 1 ),
( 3, 2, 1 );
WITH Evaluate AS
SELECT SetID,
COUNT(DISTINCT ServerID) AS Servers,
COUNT(DISTINCT ApplicationID) AS Applications
FROM @Sample
GROUP BY SetID
SELECT S.*,
CASE WHEN E.Servers != 1 THEN 1 ELSE 0 END AS ServersDifferent,
CASE WHEN E.Applications != 1 THEN 1 ELSE 0 END AS ApplicationsDifferent
FROM @Sample S
INNER JOIN Evaluate E ON S.SetID = E.SetID
ORDER BY S.SetID;
Maybe you are looking for
-
hi all, i am using Forms [32 Bit] Version 6.0.8.24.1 (Production). i am uploading data from excel to form(record wise)and saving. now i am reading the data from 2nd row by assuming that 1st row followed with columns titles.But, my question is we cann
-
Bad performance when calling a function in where clause
Hi All, I have a performance problem when executing a query that contains a function call in my where clause. I have a query with some joins and a where clause with some regular filters. But one of these filters is a function, and its input parameter
-
PDF form open in viewer not browser
I'm having a problem with a PDF form on my website. I've tested it up and down with no problems, yet I'm getting feedback that users complete the form, click "submit" and nothing happens...and I don't get the form using form central. I've determined
-
I have an Ipod Touch 4th Generation and plugged it into my TV using the Apple component cable. It works with youtube but I only get audio when I try to watch streamimg TV. The video is on the Ipod but not on the TV screen.
-
So, I'm trying to do something which I thought was fairly simple. I have a very simple record class who's only members are two strings and then there are the usual set/get methods. Let us call it class Foo. Now, I want to have a set of Foo's which ke