Home » Other » Test » Which is easier to read?
Which is easier to read? [message #434604] |
Wed, 09 December 2009 22:45 |
|
BlackSwan
Messages: 26766 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 |
|
Michel Cadot
Messages: 68716 Registered: March 2007 Location: Saint-Maur, France, https...
|
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
|
|
|
|
|
Goto Forum:
Current Time: Sat Nov 23 20:09:10 CST 2024
|