I have this table:
ID ORDER SCNID SCANNER
-------------------------------
170842 85986 20 APL-1
170843 85986 20 APL-1
170844 85986 20 APL-1
170845 85986 20 APL-1
170886 86004 200 GPL-2
170897 86011 1600 MAP-1
170900 86011 1600 MAP-1
170903 86011 1600 MAP-1
170904 86011 1600 MAP-1
170906 86011 1600 MAP-1
170908 86011 1600 MAP-1
170909 86011 1600 MAP-1
170918 86024 520 NIX-3
170922 86028 1050 OPL-3
170923 86029 1050 OPL-3
I need to make a customorderID
column for which it will look like this :
ID ORDER SCNID SCANNER CUSORDERID
--------------------------------------------
170842 85986 20 APL-1 85986-1
170843 85986 20 APL-1 85986-2
170844 85986 20 APL-1 85986-3
170845 85986 20 APL-1 85986-4
170886 86004 200 GPL-2 86004-1
170897 86011 1600 MAP-1 86011-1
170900 85986 1600 MAP-1 85986-5
170903 86011 1600 MAP-1 86011-2
170904 86011 1600 MAP-1 86011-3
170906 86011 1600 MAP-1 86011-4
170908 86011 1600 MAP-1 86011-5
170909 86011 1600 MAP-1 86011-6
170918 86024 520 NIX-3 86024-1
170922 86028 1050 OPL-3 86028-1
170923 86029 1050 OPL-3 86029-1
The rows are sorted by ID & according to the ID the 1st record's for a particualar ORDER (eg. 86011) custom ORDERID will be 86011-1, if any other records are there for that ORDER then it will be 86011-2 and so on.
Can anyone help me?