Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

WHILE LOOP with SQL statement

$
0
0
Hi Guys,

Is it possible to do a WHILE loop in a SELECT statement?

I am trying to pull a list of customers first successful purchase for a discount offer. can someone help...

DATA
CUSTID ORDERID STATUS
11111 00001 CANCELLED
11111 00002 SUCCESSFUL
22222 00003 SUCCESSFUL
33333 00004 CANCELLED
33333 00005 CANCELLED
33333 00006 SUCCESSFUL

I am doing a rank on CUSTID and ORDERID to get the transactions in order but some people have 2 or 3 cancelled orders before a successful one.

could I do a WHILE loop in the WHERE clause?

Viewing all articles
Browse latest Browse all 13329

Trending Articles