473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sql Commands for incremental values

Hi all
Need your help to do this; I got a table with these records:

Supplier RegNo Status PoNumber
ABC sbh1309m 1
DCD sbt99x 1
FGJ sbg3939m 1
FGJ sbg3939m 1
OEE ey3939d 1

Need to have a sql command to transform to :

Supplier RegNo Status PoNumber
ABC sbh1309m 1 50001
DCD sbt99x 1 50002
FGJ sbg3939m 1 50003
FGJ sbg3939m 1 50003
OEE ey3939d 1 50004

Any ideas?
Thanks in advance.
Rashid.

Jul 20 '05 #1
1 1886
It would appear that your required output is based on a transitive
dependency: (supplier,regno) -> ponumber. Therefore that information should
really be normalised into a separate table:

CREATE TABLE PO (supplier CHAR(3), regno CHAR(8), ponumber INTEGER NOT NULL
UNIQUE, PRIMARY KEY (supplier,regno))

INSERT INTO PO (supplier, regno, ponumber)
SELECT S1.supplier, S1.regno,
50000+COUNT(DISTINCT S2.regno) AS ponumber
FROM Sometable AS S1
JOIN Sometable AS S2
ON S1.supplier > S2.supplier
OR (S1.supplier = S2.supplier
AND S1.regno >= S2.regno)
GROUP BY S1.supplier, S1.regno

--
David Portas
------------
Please reply only to the newsgroup
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bangalore | last post by:
Hi In reversing string usring recursive function, i found problems in using incremental postfix , and incremental prefix 1 void rev(char*); 2 void main() 3 { 4 char s="STRING"; 5 ...
1
by: jane | last post by:
HI, I had a question on incremental backup. We had an incremental backup every weekend. We did full backup every other week. That is one week incremental + full , the other week is...
1
by: Jimmy Chen | last post by:
Recently I've done a db2 backup and restore/recovery, but the process for recovering the database was different than what I thought to be. here is what I did: DB2 is set in online mode -...
3
by: apple | last post by:
UDB v8 fp 6a on AIX 5.1.0.0 Below is a manual incremental recover from compressed backup datasets. With external compress backup datasets, can it be coded to do an automatic incremental recover?...
0
by: Willem | last post by:
Based on MK's TSI_SOON (http://www.trigeminal.com/)I've created a nifty little procedure that - whenever you compact you db you get an incremental backup copy. Given that you have a table with...
6
by: Rudy Ray Moore | last post by:
I work with a multi-project workspace. One project (the "startup" project) has a "Configuration Type" of "Application (.exe)". The other 40 projects have a "Configuration Type" of "Static Library...
3
by: Alex Shturm | last post by:
Hi, I am trying to activate incremental link using VC7 (.NET 2003) on a pretty big project (executable size is more than 100Mb, and it gets linked from several dozen of libraries and object...
5
by: Joel Matthew | last post by:
My boss was asking about incremental backups. I was scratching my head, thinking that the transaction log and a backup policy (script) for each record set (sorry about the archaic terminology)...
0
by: prerak_v_shah | last post by:
Hi All, These days I was working on IBM DB2 database for windows with my .Net Application. Now, it was required to backup database created on one machine to the other machine. I was also able...
8
by: Bern McCarty | last post by:
We have a large mixed dll that I can never seem to get to link incrementally. Below is the console output. For simplicity I've eliminated some stuff that we normally do when we really link this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.