Home » Other » Test » Which is easier to read?
Which is easier to read? [message #434604] Wed, 09 December 2009 22:45 Go to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
Select Decode(Interval, 'DAY',start_date+indx, 'MONTH',Add_Months(start_date,indx),to_char(start_date,'dd')||'/'||to_char(start_date,
'mm')||'/'||to_char(to_number(to_char(start_date,'yyyy')+indx))) From (Select t1.x1 indx, t2.x2 rfrnc From (Select rownum x1
From user_objects) t1, (select rownum x2, t.* from t) t2 Where t1.x1
<=t2.COUNT) Main1, (select rownum x3, t.* From t)main2 where main1.rfrnc = main2.x3

or

SELECT Decode(INTERVAL,'DAY',start_date + indx,
                       'MONTH',Add_months(start_date,indx),
                       To_char(start_date,'dd')
                       ||'/'
                       ||To_char(start_date,'mm')
                       ||'/'
                       ||To_char(To_number(To_char(start_date,' yyyy') + indx)))
FROM   (SELECT t1.x1 indx,
               t2.x2 rfrnc
        FROM   (SELECT ROWNUM x1
                FROM   user_objects) t1,
               (SELECT ROWNUM x2,
                       t.*
                FROM   t) t2
        WHERE  t1.x1 <= t2.COUNT) main1,
       (SELECT ROWNUM x3,
               t.*
        FROM   t) main2
WHERE  main1.rfrnc = main2.x3 

[Updated on: Wed, 09 December 2009 23:49]

Report message to a moderator

Re: Which is easier to read? [message #434619 is a reply to message #434604] Wed, 09 December 2009 23:47 Go to previous message
Michel Cadot
Messages: 64140
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Your firt query is already too clean. Most of the times there are on a single line or cut anywhere in the middle of an expression something like
Select Decode(Interval, 'DAY',start_date+indx, 'MONTH',Add_Months(start_date,indx),to_char(start_date,'dd')||'/'||to_char(start_date,
'mm')||'/'||to_char(to_number(to_char(start_date,'yyyy')+indx))) From (Select t1.x1 indx, t2.x2 rfrnc From (Select rownum x1
From user_objects) t1, (select rownum x2, t.* from t) t2 Where t1.x1
<=t2.COUNT) Main1, (select rownum x3, t.* From t)main2 where main1.rfrnc = main2.x3

Regards
Michel
Previous Topic: consistent gets and physical gets
Next Topic: Which is easier to read?
Goto Forum:
  


Current Time: Fri Dec 09 03:37:23 CST 2016

Total time taken to generate the page: 0.08270 seconds