Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Conditional Serial Number Generation

Author  Topic 

imrajesh
Starting Member

2 Posts

Posted - 2014-01-17 : 00:19:50
I need to generate the trip number (shown as below) for each carrier, truck, trip eligibility combination. if the trip eligibility has 'Y' then serial number to be continued with next number, other wise previous row serial number has to be maintained.

Anyone can help for this.?
Thanks.


Carrier Truckno TripElg TripNo SlNo
A aa Y 1 1
A aa N 1 2
A aa N 1 3
A aa Y 2 4
A aa Y 3 5
A aa N 3 6
A aa Y 4 7
A bb Y 1 8
A bb N 1 9
A bb Y 2 10
A bb Y 3 11
A bb Y 4 12
B ac Y 1 13
B ac N 1 14
B ac N 1 15
B ac Y 2 16
B ac N 2 17
B ad Y 1 18



With Thanks & Regards
Rajesh S

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-17 : 01:54:58
Answered here
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/8e8c4164-b66f-4519-8a35-c1cc243b34ca/conditional-serial-number-generation?forum=transactsql

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

imrajesh
Starting Member

2 Posts

Posted - 2014-01-18 : 00:06:26
quote:
Originally posted by visakh16

Answered here
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/8e8c4164-b66f-4519-8a35-c1cc243b34ca/conditional-serial-number-generation?forum=transactsql

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




This is working well.. thanks.

With Thanks & Regards
Rajesh S
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-18 : 02:12:27
quote:
Originally posted by imrajesh

quote:
Originally posted by visakh16

Answered here
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/8e8c4164-b66f-4519-8a35-c1cc243b34ca/conditional-serial-number-generation?forum=transactsql

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




This is working well.. thanks.

With Thanks & Regards
Rajesh S


Can you please mark it as answer then

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -