Where Condition Query Help
I have a table with following data
I need help in my where condition
ID Number Token
12100 V33 09
12103 V66 03
12103 V66 09
12105 V77 09
12106 V88 03
12106 V88 09
I want to put Token in Where condition like this
If Token is only 3 for that ID then It will show following records
ID Number Token
12103 V66 03
12106 V88 03
If User asks for Token 09 record then It will exclusively show record with 09 with not with 03 and with 09 records
So Output will be like this
ID Number Token
12100 V33 09
12105 V77 09
hi,
try this,
select
from tokenid
where
token = 09
and
number not
in(select
number from tokenid
where
token = 03
GVRSPK VENI
Similar Messages
-
URGENT: To change the where condition in select query at runtime ?
Hi,
I have to develop a report, 4 which I have created a selection screen with 7 Input Parameters whose value is to be filled by the user while executing the report.
On the basis of this I do the desired selection of output.
But the problem is that how do I write my select Query(where condition) if the user enetrs only 2 Input parameters or 3 or whatever he feels like.
Pls help me out...hi,
check this sample code.
Here i am populating where condition at runtime.
DATA: V_WHERE TYPE STRING.
SELECTION-SCREEN BEGIN OF BLOCK INPUT WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN,
S_ERDAT FOR VBAK-ERDAT.
SELECTION-SCREEN END OF BLOCK INPUT.
START-OF-SELECTION.
PERFORM POPULATE_WHERE.
PERFORM GET_VBAK_DATA.
*& Form POPULATE_WHERE
* Populate Where
FORM POPULATE_WHERE .
IF NOT S_ERDAT[] IS INITIAL.
CONCATENATE 'VBELN IN S_VBELN'
'AND'
'ERDAT IN S_ERDAT'
INTO V_WHERE
SEPARATED BY SPACE.
ELSE.
V_WHERE = 'VBELN IN S_VBELN'.
ENDIF.
ENDFORM. " POPULATE_WHERE
*& Form GET_VBAK_DATA
* GET VBAK DATA
FORM GET_VBAK_DATA .
SELECT VBELN
ERDAT
VBTYP
NETWR
WAERK
VKORG
VTWEG
SPART
INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
FROM VBAK
WHERE VBELN IN S_VBELN
AND ERDAT IN S_ERDAT.
WHERE (V_WHERE).
endform.
Regards
Sailaja. -
Select query with optional where condition
Hi,
Can Anybody help me out in the following problem?
I have the following query in a procedure.
SELECT replace(shipper_name,'\',' ') as shipper,
sum(teus / cntSailings) as teus
FROM VW_CONTRIBUTION,
VW_TOTAL_SAILINGS
WHERE VW_CONTRIBUTION.dir = VW_TOTAL_SAILINGS.DIR
AND VW_CONTRIBUTION.line = VW_TOTAL_SAILINGS.LINE
AND VW_CONTRIBUTION.accounting_month = VW_TOTAL_SAILINGS.ACCOUNTING_MONTH
AND VW_CONTRIBUTION.accounting_year = VW_TOTAL_SAILINGS.ACCOUNTING_YEAR
AND VW_CONTRIBUTION.Principal = arg_principal
AND VW_CONTRIBUTION.Dir = arg_direction
AND VW_CONTRIBUTION.line in ( arg_service )
AND VW_CONTRIBUTION.POL_country = arg_pol
AND VW_CONTRIBUTION.POd_country = arg_pod
AND VW_CONTRIBUTION.salesOffice = arg_SalesOffice
AND VW_CONTRIBUTION.salesregion = arg_SalesRegion
AND VW_CONTRIBUTION.cargo_type = arg_txtCargoType
AND VW_CONTRIBUTION.eqgroup = arg_ContType
AND VW_CONTRIBUTION.eq_size = arg_txtSize
AND VW_CONTRIBUTION.acct_date between arg_from_date and arg_end_date
GROUP BY shipper_name
ORDER BY teus desc;
Here some of the arguments are optional(Eg : VW_CONTRIBUTION.salesOffice, AND VW_CONTRIBUTION.eqgroup etc. ) and the values can be null. When they are null, I want them to be excluded from the where condition. Can anybody suggest me a solution for this?
Thanks,
Shalet.I guess i misunderstood your original question.
The clause
AND (VW_CONTRIBUTION.salesOffice = arg_SalesOffice OR VW_CONTRIBUTION.salesOffice IS NOT NULL)
will cause the where clause to evaluate to FALSE anytime salesOffice IS NULL so the record will be excluded.
I thought you were asking how to not compare the value if the field contained a NULL.
Glad you found what you wanted. -
Single SQl Query with different where conditions
Experts,
I have a requirement to design a report. Here are the details
I have Report table layout
Profit center Gross sales (This Year) Gross Sales (Last Year) % change Year of Year
The Report has a selection of entering the Start Date.
I have a single table in oracle which has profit center and Gross Sales Values on daily basis.
I want to write a single sql query to calculate both Gross Sales current year and Gross Sales Last Year. I can calculate Gross Sales Current Year by putting the where condition for start date = Current Year Date which i pass through report. I want to calculate the Gross Sales Last Year in the Same query by putting the different where condition i.e start date = Last Year date based on the date input.
I dont know how to put two where conditions in single query for two different columns.
Any help will be appreciated.
Thanks in advance
Regards
Santoshinstead of changing your where clause couldn't you just determine the yearly totals from your table and then use the lag statement to get last years total?
something like this?
I just made up 10,000 days worth of sales and called it fake table it is supposed to represent a variant of the table you were describing as your base table.
with fake_table as
( select trunc(sysdate + level) the_day,
level daily_gross_sales
from dual
connect by level < 10001
select yr, year_gross_sale, lag(year_gross_sale) over (order by yr) prev_year_gross_sale,
(year_gross_sale - lag(year_gross_sale) over (order by yr))/year_gross_sale * 100 percent_change
from
(select distinct yr, year_gross_sale from
select the_day,
daily_gross_sales,
extract(year from the_day) yr,
extract(year from add_months(the_day,12)) next_yr,
sum(daily_gross_sales) over (partition by extract(year from the_day)) year_gross_sale
from fake_table
order by yr
) -
Checkbox Value in where condition of query
Hi,
I have a check box which shows values based on the LOV's . If i check on the checkbox the values that are selected on the check box must be used in the where condition to update the table.
Please suggest me how to take the check box values.
Am using the below methos to update but its not happening
Declare
old_cohort_name varchar2(500);
new_cohort_name varchar2(500);
l_cohort_id apex_application_global.vc_arr2;
begin
l_cohort_id := apex_util.string_to_table(:P64_CASCADE_COHORT_NAMES);
select cohort_name into old_cohort_name from study_cohort
where cohort_id = :p64_cohort_id;
select :P64_COHORT_NAME into new_cohort_name from dual;
if old_cohort_name <> new_cohort_name then
update study_cohort
set
cohort_name = new_cohort_name
where cohort_id = :p64_cohort_id and
cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked
End if;
End;
Please suggest me how to modify the code
Tx
SudhriHi Sudhri,
where cohort_id = :p64_cohort_id and
cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked If this is the code you are actually using, then the condition would only be met if l_cohort_id = :p64_cohort_id because you are using an AND condition over the same column in the where clause, so it will only return rows when both values are the same. Then, I think that it seems not to be working for you because :p64_cohort_id and l_cohort_id have different values, and no row is getting updated then. If the values you are selecting in your checkboxes are several ids of rows to update, besides the one with id :p64_cohort_id, then maybe the condition you need is something like this:
WHERE cohort_id = :p64_cohort_id OR instr(l_cohort_id, cohort_id) != 0;Hope that helps.
Regards,
Sergio -
How Can I Change the Where Condition In the First SQL Query?
SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT,
TRUNC(MONTHS_BETWEEN((TO_DATE('19'||END_SVC_DT,'YYYYMMDD')),BEG_SVC_DT)/12),
mod(trunc(months_between((to_date('19'||end_svc_dt,'YYYYMMDD')),BEG_SVC_DT)),12),
DECODE((SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1),-1,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-2,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-3,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-4,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-5,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-6,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-7,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-8,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-9,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-10,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-11,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-12,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-13,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-14,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-15,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-16,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-17,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-18,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-19,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-20,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-21,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-22,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-23,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-24,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-25,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-26,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-27,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-28,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-29,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-30,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-31,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
30,0,
(SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1))
FROM SVC_OCCURRENCES
WHERE end_svc_dt not in ('PRESENT')
AND SUBSTR(END_SVC_DT,1,1) IN '9'
AND SUBSTR(END_SVC_DT,5,2) NOT IN ('31')
and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
UNION
SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT, NULL, NULL, NULL
FROM SVC_OCCURRENCES
WHERE SUBSTR(END_SVC_DT,1,1) IN 'P'
The above code works fine and I get the correct numeric values from the SQL
query when the varchar2 end_svc_dt field is numeric however if I have encoded
the word 'PRESENT' in the varchar2 end_svc dt field the SQL query aborts at
the last statement in the WHERE condition. The beg_svc_dt field is a Date field.
and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
I get the following error message
ERROR ORA-0722 INVALID NUMBER
I encode the word 'PRESENT' in a varchar2 end_svc_dt field on an Oracle form. This is the only word that can be encoded.
Is there some way that I can bypass the last statement in the where condition and
compute the values from the SQL query without having the SQL query abort?
Eventually I want to do this in a report. I know that this sounds strange but can it be done?The above code works fine and I get the correct
numeric values from the SQL
query when the varchar2 end_svc_dt field is numeric
however if I have encoded
the word 'PRESENT' in the varchar2 end_svc dt field
the SQL query aborts at
the last statement in the WHERE condition.Ouch!
Storting dates in VARCHAR2 columns is bad practice, poor design and makes for horrible code.
The beg_svc_dt field is a Date field.
and (SUBSTR(END_SVC_DT,5,2) -
SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')If it's a date field then why on earth are you trying to SUBSTR it. SUBSTR = sub-string i.e. take a sub section of a string not sub-date.
I get the following error message
ERROR ORA-0722 INVALID NUMBERAnd you're surprised by this?
Is there some way that I can bypass the last
statement in the where condition and
compute the values from the SQL query without having
the SQL query abort?Store your dates properly, use additional flag columns for non-date information and code your SQL properly.
Eventually I want to do this in a report. I know
that this sounds strange but can it be done?Yes, most things are possible. -
How to use wildcards in ABAP query where condition?
Hi,
Please tell me how to use wildcards in ABAP qurey where condition.
e.g. select * from mara where matnr = * (wildcard we need to use.
Thanks & Regards,
Gaurav TDo you want to query asterix * ?
select * from mara where matnr = '*'. "then just put it in apstrophes
or you want certain part of string be used as * ?
select * from mara where matnr like '%*' "then use % sign before it
or maybe you want something like this
select * from mara where matnr like '%1' . "then it will look for all materials having '1' inside it
Regards
Marcin -
Dynamic select query with dynamic where condition
Hi all,
I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
Please advice, if there is any other way to achieve this requirement.
Thanks,
Sanket Sethi
Code***************
PARAMETERS: p_tabnam TYPE tabname,
p_selfl1 TYPE edpline,
p_value TYPE edpline,
p_where1 TYPE edpline .
DATA: lt_where TYPE TABLE OF edpline,
lt_sel_list TYPE TABLE OF edpline,
l_wa_name TYPE string,
ls_where TYPE edpline,
l_having TYPE string,
dref TYPE REF TO data,
itab_type TYPE REF TO cl_abap_tabledescr,
struct_type TYPE REF TO cl_abap_structdescr,
elem_type TYPE REF TO cl_abap_elemdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp_fld TYPE cl_abap_structdescr=>component.
TYPES: f_count TYPE i.
FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
* <ls_outtab> TYPE ANY,
<l_fld> TYPE ANY.
struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
elem_type ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
comp_tab = struct_type->get_components( ).
comp_fld-name = 'F_COUNT'.
comp_fld-type = elem_type.
APPEND comp_fld TO comp_tab.
struct_type = cl_abap_structdescr=>create( comp_tab ).
itab_type = cl_abap_tabledescr=>create( struct_type ).
l_wa_name = 'l_WA'.
CREATE DATA dref TYPE HANDLE itab_type.
ASSIGN dref->* TO <lt_outtab>.
*CREATE DATA dref TYPE HANDLE struct_type.
*ASSIGN dref->* TO <ls_outtab>.
* Creation of the selection fields
APPEND p_selfl1 TO lt_sel_list.
APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
** Creation of the "where" clause
*CONCATENATE p_selfl1 '= '' p_value ''.'
* INTO ls_where
* SEPARATED BY space.
*APPEND ls_where TO lt_where.
* Creation of the "where" clause
APPEND p_where1 TO lt_where.
* Creation of the "having" clause
l_having = 'count(*) >= 1'.
* THE dynamic select
SELECT (lt_sel_list)
FROM (p_tabnam)
INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
* WHERE (lt_where).Hi Sanket,
The above given logic of mine works for you, put the code in the If condition and try-
just like below:
IF NOT P_EBELN IS INITIAL.
lt_where = '& = ''&'' '.
REPLACE '&' WITH p_ebeln INTO lt_where.
REPLACE '&' WITH field_value INTO lt_where.
SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
FROM (p_tabnam)
WHERE (lt_where).
ENDIF.
thanks\
Mahesh -
Query help....three conditions
Hi All,
I have a table with the following data
empno emptype empstatus
1 best Active
2 good drop
3 best Active
1 good cancel
4 good left
5
This table consists of three columns
Emptype has two distinct values - good,best
Empstatus consists of one status - Active for best type
Empstatus consists of three status - Drop,cancel,left for good type.
One emp can get either any one of these three status in good type
The highest level of type is best followed by good
An emp can get both the types
I need to get the highest level of status achieved so far for an emp
For example, emp 1 has got both best and good types
Then the output for emp 1 will be
empno higheststatus
1 Active
If the emp didnot get any, it should display NULL.
The output for the above data should be
empno higheststatus
1 Active
2 drop
3 Active
4 left
5
Thank u for ur help !!880186 wrote:
Hi Frank,
thank you for the logic....
But the data is not showing up correctly... its not showing any of cancel or left empstatusYou said you would accept any of the 3:
if an empno consists of only emptype as good then the higheststatus is any of the three - drop,cancel,leftIf you'd rather have 'cancel', then use 'cancel'. If you'd rather have 'left', then use 'left'. If you want 'cancel' sometimes, and 'drop' at other times, and 'left' at other times, explain how you decide which one you want. If you can say it in English, someone will help you do it in SQL.
nly the higheststatus is showing up as Active/ drop.....Point out exactly where the query I posted is giving the wrong results, and explain how you get the right results in those places.
Also, I couldn't understand it exactly...
What does max function do here ?
, CASE
WHEN COUNT (DISTINCT emptype) = 2
THEN 'Active'
WHEN MAX (emptype) = 'best'
THEN 'good'
WHEN MAX (emptype) = 'good'
THEN 'drop' -- or 'cancel', or 'left'
END AS highestempstatusYou said there were only 2 possible values for emptype: 'best' and 'good'. The requirements you posted were
If an empno consists of both emptype, then the higheststatus is Active
If an empno consists of only emptype as best then the higheststatus is good
if an empno consists of only emptype as good then the higheststatus is any of the three - drop,cancel,left
if an empno consists of none empstatus, the it will be blankThe CASE expression above does that, in that order. By the time the second WHEN clause
WHEN MAX (emptype) = 'best'is evaluated, we know that there are not 2 distinct emptypes present for this empno. 2 is the maximum number possible, so, if there are not 2 distinct values, there must be 1 or 0 dstinct values. The next 2 WHEN clauses test whether there is 1 value for emptype. If there are 0 values, then MAX will return NULL, and the WHEN clause will not be TRUE. If there is 1 value of emptype, then MAX will return that value. (MIN will also return that value; it doesn't matter if you use MIN or MAX in this case.) -
Hi Folks,
i am trying to write a where Used Query for the child items.
SELECT ITT1.Father 'Item Code',BOM= Case OITT.Treetype When 'S' then 'Sales BOM' Else 'Production BOM' End FROM OITT INNER JOIN ITT1 ON OITT.Code = ITT1.Father INNER JOIN OITM ON ITT1.Code = OITM.ItemCode where OITM.ItemCode=$[$5.0.0]
Everything works fine but when i am trying to bring back the item description in the report it brings the description of the Child item instead of the Parent. So i am looking for a query which will show the parent item, description and bom type for the child item.Hi,
Try this one:
SELECT T1.Father 'Item Code',BOM= Case T0.Treetype When 'S' then 'Sales BOM' Else 'Production BOM' End, T3.ItemName, T1.Code
FROM OITT T0 INNER JOIN T1 T1 ON T0.Code = T1.Father
INNER JOIN OITM T2 ON T1.Code = T2.ItemCode
INNER JOIN OITM T3 ON T0.Code = T3.ItemCode
where T2.ItemCode=$[$5.0.0\]
Thanks,
Gordon -
Query in SQL to display count of all records but where condition is present
Hi All,
I have situation where I need to display count of all records all particular period but in where condition type condition has to be present :
Please find the below sample data :
PERIOD_ID TYPE MV_COUNT IS_FLAG
20110401 AM 1 0
20110401 AM 1 0
20110401 MS 29 0
20110501 MS 1 0
20110601 MS 14 0
20110701 MS 2 0
20110401 MS 1 0
20110401 AM 2 0
20110401 AM 69 0
20110401 AM 2 0
finally I need for type = MS
i) total is_flag count for all the periods
ii) for period=20110501 what is the mv_count
I need to use the table single time (ie not self join outer joins )
I have tried to use partition by clause but it will filter out the data .
Cheers,
Sp842106 wrote:
finally I need for type = MS
i) total is_flag count for all the periods
ii) for period=20110501 what is the mv_count
I need to use the table single time (ie not self join outer joins )
I have tried to use partition by clause but it will filter out the data .
select sum(is_flag) is_flg_count,
sum
case when period = 20110501 then mv_count else 0 end
) mv_cnt_for_20110501
from your_table
where type = 'MS'; -
Please help - NE where condition in SELECT statement
Dear experts,
I am posting a section of my codes here for your review on performance tuning.
In my second select statement, I used a "NE" where condition. I read somewhere in this forum that using "NE" where condition is not a good decision for improving codes' performance. What alternatives can I have to achieve the same purpose? May I use "NOT IN" here instead? Or do I use a LOOP for this (a rather manual way)?
Just to let you all know that I still consider myself quite inexperienced in ABAP - please also let me know how I can better improvise my programming techniques in the posted codes here too.
I will be most glad to provide you with further information if needed - just let me know.
Many THANKS in advance!
IF p_noncis = 'X'. " Non CIS category of spend selected
" zfi_cis_mat_grp is a bespoke table that stores all CIS MATKL
" and it has two fields only - MANDT and MATKL
SELECT * FROM zfi_cis_mat_grp
INTO TABLE gt_cis_mat_grp.
IF gt_cis_mat_grp IS NOT INITIAL.
SELECT ebeln
ebelp
matkl
FROM ekpo
INTO TABLE gt_ekpo
FOR ALL ENTRIES IN gt_cis_mat_grp
WHERE matkl NE gt_cis_mat_grp-matkl. " NE where condition - is this OK?
ENDIF.
IF gt_ekpo IS NOT INITIAL.
IF s_sakto IS NOT INITIAL.
SELECT ebeln
ebelp
sakto
FROM ekkn
INTO TABLE gt_ekkn
FOR ALL ENTRIES IN gt_ekpo
WHERE ebeln = gt_ekpo-ebeln AND
ebelp = gt_ekpo-ebelp AND
sakto IN s_sakto.
IF gt_ekkn IS NOT INITIAL.
SELECT bukrs
lifnr
belnr
budat
cpudt
xblnr
ebeln
ebelp
zfbdt
zterm
zlspr
FROM bsik
INTO TABLE gt_bsik
FOR ALL ENTRIES IN gt_ekkn
WHERE bukrs IN s_bukrs AND
lifnr IN s_lifnr AND
budat IN s_budat AND
cpudt IN s_cpudt AND
xblnr IN s_xblnr AND
ebeln = gt_ekkn-ebeln AND
ebelp = gt_ekkn-ebelp AND
qsskz NE ''.
ENDIF.
ELSE.
SELECT bukrs
lifnr
belnr
budat
cpudt
xblnr
ebeln
ebelp
zfbdt
zterm
zlspr
FROM bsik
INTO TABLE gt_bsik
FOR ALL ENTRIES IN gt_ekpo
WHERE bukrs IN s_bukrs AND
lifnr IN s_lifnr AND
budat IN s_budat AND
cpudt IN s_cpudt AND
xblnr IN s_xblnr AND
ebeln = gt_ekpo-ebeln AND
ebelp = gt_ekpo-ebelp AND
qsskz NE ''.
ENDIF.
ENDIF.
ELSE. " Complete list of category of spend selected
SELECT bukrs
lifnr
belnr
budat
cpudt
xblnr
ebeln
ebelp
zfbdt
zterm
zlspr
FROM bsik
INTO TABLE gt_bsik
WHERE bukrs IN s_bukrs AND
lifnr IN s_lifnr AND
budat IN s_budat AND
cpudt IN s_cpudt AND
xblnr IN s_xblnr AND
qsskz NE ''.
ENDIF.Hi,
If you want to remove th NE option then try this way..
SELECT bukrs
lifnr
belnr
budat
cpudt
xblnr
ebeln
ebelp
zfbdt
zterm
zlspr
FROM bsik
INTO TABLE gt_bsik
WHERE bukrs IN s_bukrs AND
lifnr IN s_lifnr AND
budat IN s_budat AND
cpudt IN s_cpudt AND
xblnr IN s_xblnr .
IF SY-SUBRC EQ 0.
Delete gt_bsik where qsskz EQ ' '.
ENDIF. -
Simple query help in plsql - help
oracle version : 10gR2
indexes are created on each column, is there anyway to make them used while searching for the records rewriting the following query to test given data in any case (lower ,upper)...
SELECT * FROM TX_USERS
WHERE userid like decode( UPPER('Md'),null,userid, UPPER( 'MD')||'%' ) and
first_name like decode(UPPER('Na'),null, first_name, UPPER( 'NA')||'%' ) AND
LAST_name like decode(('Ra'),null, LAST_name, UPPER('RA')||'%' )
-- list goes on..
UPPER('Md') -- is the input values comes from form.. for example i_userid.. this query works fine .. is there anyway of getting indices used without using functional based indexing when we rewrite query like shown below??? input parameter valeus can be anything and table column values can be anything i.e. anycase (upper or lower or mix of both)..
actual code would be
upper(userid) like decode( UPPER(i_userid),null,userid, UPPER( i_userid)||'%' ) and
upper(first_name) like decode(UPPER(i_first_name),null, first_name, UPPER( i_firstname)||'%' )
if we put upper(userid) then index not used ..........anyway of rewriting using it or any other technique... or any other new wayNo, its not working... see the below..
create table test5 as select owner, object_name, subobject_name, object_type from all_objects;
create unique index test5_i5 on test5 (owner, object_name, subobject_name, object_type);
select * from test5 where owner like 'SCOTT' AND OBJECT_NAME LIKE 'EMP';
INDEX RANGE SCAN| TEST5_I5 | 4 | 248 | 1 (0)| 00:00:01 |
but when i use
select * from test5 where UPPER(OWNER) LIKE 'SCOTT%' AND UPPER(OBJECT_NAME) LIKE 'EMP%';
TABLE ACCESS FULL| TEST5 | 3 | 186 | 65 (5)| 00:00:01 |
i know it goes to full scan, i want to know is there any other way to make index used .. without using functional based indx...
the reason is user can search any one of the column data and data is mixed case in table columns and/or conditions specified in query..
.. any help...
not sure how to use 'NLS_SORT=BINARY_CI' on multicolumn index and enable index used in search operation.. ANY OTHER WAY OF DOING THIS...
requirements is
mixed (lower,upper) data stored in db columns and mixed case data searched, 5 columns specified in where condition, data may be provided in search conditon to one or two or to all 5 columns in mixed case... matching records need to be returned.. suggest a good way of doing this... thnx -
CASE Statement in Where Condition with Multi Valued parameter in SSRS
Hi All,
I am little confused while using CASE statement in Where condition in SSRS. Below is my scenario:
SELECT
Logic here
WHERE
Date IN (@Date)AND
(CASE
WHEN NAME LIKE 'ABC%' THEN 'GROUP1'
WHEN ID IN ('123456', '823423','74233784') THEN 'GROUP2'
WHEN ABC_ID IS NULL THEN 'GROUP3'
ELSE 'GROUP4'
END ) IN (@GROUP)
So above query uses WHERE condition with CASE statement from @GROUP parameter. I want to pass this parameter as multi- valued parameter and hence I have used CASE statement IN (@GROUP).
For @Date one dataset will pass the available and default values and
for @GROUP parameters, another dataset will pass the available and default values.
But this is not working as expected. Please suggest me where I am making mistake in the query.
Maruthu | http://sharepoint-works.blogspot.comHi Maruthu,
According to your description, I create a sample report in my local environment. It works as I expected. In your scenario, if the selected values from the Date parameter contains some of the Date field values, the selected values from the GROUP parameter
contains some of GROUPS (‘GROUP1’,’GROUP2’,’GROUP3’,’GROUP4’) and the corresponding when statement is executed , then the dataset returns the corresponding values.
In order to trouble shoot this issue, could you tell us what results are you get and what’s your desired results? If possible, you can post the sample data with sample dataset, then we can make further analysis and help you out.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Concatenation error - when i use text column value in where condition.
Hi,
i am creating Materialized view using few columns from two tables and as per requirement i need to prepare select statement with where condition in another column.(new column)
i tried like below....
create materialized view MAIN
refresh force on demand
as
select
a.table_name,
a.column_name,
b.trial_name,
'select * from '||a.table_name||' where '||a.column_name|| ' = '|| b.trial_name||';' "QUERY"
from
exp_csv_tB a,
exp_csv_tr b;
a.table name value is : monitoring_table
a.column_name value is : study
b.trial_name = fty777
Materialized view created with extra column but it is not added '' (codes) to text value in where condition.
output which i got is :
select * from monitoring_table where study = fty777;
but
i need output like
select * from monitoring_table where study = 'fty777';
fty777 value should be in codes like 'fty777'. i read some articles but didnt get this example.
please help.Try this:
CREATE MATERIALIZED VIEW main
REFRESH FORCE ON DEMAND
AS
SELECT
a.table_name,
a.column_name,
b.trial_name,
'select * from '||a.table_name||' where '||a.column_name|| ' = '''|| b.trial_name||'';'' "QUERY"
FROM
exp_csv_tb a,
exp_csv_tr b;
You have to give double single codes for semi-colons ..
Regards..
Maybe you are looking for
-
Yoga 2 Pro Resolution Scaling Issues
So I just picked this laptop up from Best Buy the other day and so far I am loving it. However that is not to say that it has been entirely without issues so far and I do apologize if this issue has been brought up before but I was unable to find a d
-
Javascript in xsl transformation in workshop
Hi I try to import an xsl file that includes javascript, and try to do a transformation from one XML format to another. I get errormessages. Is javascript in xsl supported in workshop ?
-
Hi there one year ago I request to open a section for Persian language (RTL) on wiki but you told me to go over archlinux.ir. there was a discussion about it in archlinux.ir but had no result. After that I start to write about beginners guide and no
-
I have a couple of different title elements on different tracks. Is there a way that I can lock these elements together then resize and move them, like you can in Photoshop? I need them to stay the same size in relation to the other elements that I w
-
A few days ago, my MPB started to be really slow. Everything takes time, I cannot use several applications at the same time anymore, or nothing works. I tried cleaning the disk and I deleted all useless applications. I have 422Go/499Go of free storag