cursor

Data Modeling

cursor

I'm trying to create a cursor with the following statement but not sure from where to start. Please help!

SELECT 
tom.wh_no AS tom_wh_acc
,tom.wh_cust AS tom_wh_cust
,bob.wh_cust AS bob_wh_cust
,bob.clustering
,tom.clus_no

FROM 
(
SELECT 
--Wh_ACC_No ,
MIN(cluster_no) AS clustering
,wh_cust
FROM 
t_mortg_rel_temp
GROUP BY 2
) bob
, t_mortg_rel_temp tom
WHERE bob.wh_cust = tom.wh_cust
AND bob.clustering <> tom.clus_no
ORDER BY bob.clustering