Re: Sequence
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/17/04
- Next message: Paul: "SQL Licence for twin processor"
- Previous message: Hugo Kornelis: "Re: Null values"
- In reply to: Mike: "Sequence"
- Next in thread: Mike: "Re: Sequence"
- Reply: Mike: "Re: Sequence"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Aug 2004 00:43:44 +0200
On Tue, 17 Aug 2004 14:38:27 -0700, Mike wrote:
>I need to create sequence numbers for a column in a table,
>I wanted to find out how can I create it?
>
>I have a column, depending if the file type ='A'
>the fileNumber should be 'A001'
>The next record could have the file type='B', in this
>case the filenumber should be 'B001',
>if the next file type = 'A', the filenumber should be
>'A002',
>if the next file type = 'A', file number should be 'A003',
>if the next file type = 'B', file number should be
>'B002', so on...
>
>I want to maintain more than one sequences for a column
>and each one should preceed with an ALPHA.
>What's the best way to do this?
>
>Remeber, I can't define it in EM as the sequence changes
>with file type.
>
>Thanks in advance for your help!
>-Mike
Hi Mike,
In a relational database, a table is by definition UNordered. There is no
such thing as a "first", "last" or "next" row. Those terms only start
making sense if they're put in the context of some ordering: the first
exployee sorted by age, the second-best selling salesman, etc.
If you have some way to decide why one A should be A001 and another should
be 002 (and not vice versa), then I can help you. But for that, I need the
following information:
* Table structure, posted as DDL (that is: CREATE TABLE statements,
including all constraints but omitting irrelevant columns);
* Sample data, posted as INSERT statements that I can copy and paste into
Query Analyzer to recreate your test data;
* Expected output based on the provided sample data.
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Paul: "SQL Licence for twin processor"
- Previous message: Hugo Kornelis: "Re: Null values"
- In reply to: Mike: "Sequence"
- Next in thread: Mike: "Re: Sequence"
- Reply: Mike: "Re: Sequence"
- Messages sorted by: [ date ] [ thread ]