a=[4,7,3,2,5,9]
for i in a:
print(str(i)+' is in the position '+ str(a.index(i)+1))
Output:
4 is in the position 1 7 is in the position 2 3 is in the position 3 2 is in the position 4 5 is in the position 5 9 is in the position 6
A highly motivated and ambitious individual able to give timely and accurate advice, guidance, support and training to team members and individuals. Having the ability to work with the minimum of supervision whilst leading a team. Having a proven ability to lead by example, consistently hit targets, improves best practices and organizes time efficiently.
a=[4,7,3,2,5,9]
for i in a:
print(str(i)+' is in the position '+ str(a.index(i)+1))
Output:
4 is in the position 1 7 is in the position 2 3 is in the position 3 2 is in the position 4 5 is in the position 5 9 is in the position 6
my_str = "Welcome to Python"
# breakdown the string into a list of words
words = my_str.split()
# sort the list
words.sort()
# display the sorted words
print("The sorted words are:")
for word in words:
print(word)
Output:
Sorted words are: Python Welcome to
my_str = "AbcdDCBa"
+---- high water mark of newly created table | V +--------------------------------------------------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ high water mark after inserting 10,000 rows | v +--------------------------------------------------------+ |x |x |x |x |x |x |x |x |x |x |x |x | | | | | | | | |x |x |x |x |x |x |x |x |x |x |x |x | | | | | | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ high water mark after inserting 10,000 rows | v +--------------------------------------------------------+ |x |x |x |x |x |x |x | | | | | | | | | | | | | |x |x |x |x |x |x |x | | | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
SQL> select * from t1;
DEPT DATE1
---------- ---------
100 01-JAN-13
100 02-JAN-13
200 03-JAN-13
100 04-JAN-13
select dept,
date1,
rank () Over (partition by dept order by date1) rnk
from t1
order by date1;
DEPT DATE1 RNK
---------- --------- ----------
100 01-JAN-13 1
100 02-JAN-13 2
200 03-JAN-13 1
100 04-JAN-13 3
DEPT DATE1 RNK
---------- --------- ----------
100 01-JAN-13 1
100 02-JAN-13 2
200 03-JAN-13 1
100 04-JAN-13 1 <<<----------
Solution:
select dept, date1,
CASE WHEN StartFlag = 0 THEN 1
ELSE 1+StartFlag+NVL(lag(StartFlag) over (order by date1),0)
END as rnk
from (select t1.*,
(case when dept = lag(dept) over (order by date1)
then 1
else 0
end) as StartFlag
from t1
) t1
order by date1;
INS INTO KBB VALUES('2014-01-01','A');
INS INTO KBB VALUES('2014-01-02','A');
INS INTO KBB VALUES('2014-01-03','D');
INS INTO KBB VALUES('2014-01-04','A');
INS INTO KBB VALUES('2014-01-05','D');
INS INTO KBB VALUES('2014-01-06','A');
FROM KBB