01-29-2007 8:58 AM
hi all,
may i know how to write a select statement to select datum2 if datum2 is greater than datum1 else select datum1.
datum1 and datum2 in tableB. tableA inner join with tableB.
thanks
01-29-2007 9:02 AM
hi,
1. select the records into an internal table.
2. Use READ statement to fetch datum1 and datum2 rom that itab
3. use IF condition to find the bigger one among the dates.
Rgds
Anver
01-29-2007 9:05 AM
Hi,
I think you need two queries since we cannot have the select clause dynamic.
Ideal would be SELECT DATUM2 FROM TABLEA INNER JOIN TABLEB ON
-
-
WHERE DATUM2> DATUM1 AND.....
if sy-subrc of this is not 0 then directly fetch DATUM1 with same where clause.
Regards,
Sesh
01-29-2007 9:05 AM
Hi,
I think you need two queries since we cannot have the select clause dynamic.
Ideal would be SELECT DATUM2 FROM TABLEA INNER JOIN TABLEB ON
-
-
WHERE DATUM2> DATUM1 AND.....
if sy-subrc of this is not 0 then directly fetch DATUM1 with same where clause.
Regards,
Sesh
01-29-2007 9:06 AM
i think it is not possible in sql...
but you can try like this..
data : v_date1 like sy-datuem,
v_date2 like sy-datuem.
select bbate1 bdate2 into (v_date1, v_date2) from dbtab as a inner join dbtab1 as b on af1 = bf1 where <condn>
if v_date1 ge v_date2.
itab-date = v_date1.
else.
itab-date = v_date2.
endif.
append itab.
endselect.
regards
shiba dutta
01-29-2007 9:08 AM
hi
Selection should be unique (Fields) when you are hitting the database table. Even if you work around some way of selectiong it, it would not be suggestable. So you better get all the records into an internal table and then use your conditions to modify the same or have an other internal table to have the actual data.
or.
1.
Select dat1
from tab1
into table itab
where dat1 gt dat2.
2.
Select dat2
from tab1
appending table itab
where dat1 lt dat2.
-
Santosh