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 2005 Forums
 Transact-SQL (2005)
 searching a sequence in column

Author  Topic 

sanjay2988
Starting Member

16 Posts

Posted - 2009-01-06 : 05:17:55
table is like this ---

TicketID ActionCode strTransDescription
1 item small pepsi
1 item small coke
1 DD Discount
1 VX Void
1 TX Tax paid
2 DC Drawer closed
2 TX Tax paid
2 DD Discount and like this point of sale items
Question is ---
I want to search those TicketID where transactions are in a sequence given by operator. For eg :- item, VX, TX is searched. In ticketID 1 the sequence is followed (means first item come then VX and TX) so 1 is returned... but in ticketID 2 item is not present so it will not come.... if( TX comes before VX then it should not return 1

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-01-06 : 05:53:38
You have a column which defines your sequence ?
Go to Top of Page

sanjay2988
Starting Member

16 Posts

Posted - 2009-01-06 : 06:01:04
i have list of action code operator can give a sequence in listbox. we can put it in temp table as one column or can pass at runtime...
Go to Top of Page

sanjay2988
Starting Member

16 Posts

Posted - 2009-01-06 : 08:42:04
Reply i am in great need
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-06 : 08:48:37
quote:
Originally posted by sanjay2988

table is like this ---

TicketID ActionCode strTransDescription
1 item small pepsi
1 item small coke
1 DD Discount
1 VX Void
1 TX Tax paid
2 DC Drawer closed
2 TX Tax paid
2 DD Discount and like this point of sale items
Question is ---
I want to search those TicketID where transactions are in a sequence given by operator. For eg :- item, VX, TX is searched. In ticketID 1 the sequence is followed (means first item come then VX and TX) so 1 is returned... but in ticketID 2 item is not present so it will not come.... if( TX comes before VX then it should not return 1


as sakets told you should have some column which designates the order. sql table does not have anything like first or last. you need to specify order based on a column value for you to determine sequence of arrival of values. May be an identity column or audit trail column like dateentered will be sufficient.
Go to Top of Page

sanjay2988
Starting Member

16 Posts

Posted - 2009-01-06 : 10:50:54
i want to search occurance of values in a column. In above table i want those tickets having sequence of transactions given by user.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-06 : 10:55:37
quote:
Originally posted by sanjay2988

i want to search occurance of values in a column. In above table i want those tickets having sequence of transactions given by user.


sequence of transaction given by user? how will they be inputting values as? also what column in table will determine the sequence in which you should search?
Go to Top of Page
   

- Advertisement -