Where condition for a column in BMM
Hi Gurus,
I have a requirement where in the BMM(The LTS for this logical table is say 'Fact'), I need a logical column with the following definition.
count(Dim.status) where Dim.status = ' Accepted' (I didnt add the Dim table to the LTS yet, should I?)
I know that we can do a count(Dim.status) in the column source . but for the where Dim.status = ' Accepted' part im not sure what to do.
Should I bring the Dim table as a LTS and define the 'where' condition in the content tab? will that work?
but what if I have another logical column where I need dim.Status = 'Declined'( we have many more status)
Plz help
The suggest statement as Filter(count(Fact.Dollars) Using("dim.status = 'accepted'))
is based on Answers, this would care about the column is available in Subject Area or not thats it.
The same kind of functionality can get the using rpd.
There you might need to map/add (fact source properties and then map using pencil icon on 11g add button in 10g) the dim table to the fact
so that you can get the expression based on physical columns as
case when dim.status = 'accepted' then Fact.Dollars else 0 end
use Aggregate tab for sum;
Since you are using Fact.Dollars it suppose to be sum, ROW_WIDs go by counts
Hope this helps :) for more Qs send email
If helps mark
Similar Messages
-
Where condition on date column using OleDb Command?
Hi,
How to read date column from excel sheet usign OleDb command. Below code failing .
OleDbCommand cmd = new OleDbCommand("SELECT Column1 FROM [sheet1$] WHERE createdDate < ="+Convert.ToDateTime("3/24/2015")+" ", connection);
OleDbDataReader dr = cmd.ExecuteReader();
Syntax error (missing operator) in query expression 'LastRun < =3/24/2015 12:00:00 AM'.
How to write a where condition on date column excel sheet?
Thanks
PS.Shakeer HussainHi PS.Shakeer Hussain,
In Excel, we store these data in excel is string type. Based on your code, it is dataTime type. So if fails when compare with dataTime and string.
Please try the following code, Useing DateTime.ToOADate Method to convert to the equivalent OLE Automation date. It works fine on my side.
OleDbDataAdapter dbAdapter = new OleDbDataAdapter("select * from [Sheet1$] WHERE createdDate < "+DateTime.Parse("3/29/2015").ToOADate(), connExcel);
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Different conditions for different columns
Hi,
I have two tables and both have 3 common columns. I have to write a query joining the two tables and get different columns with different conditions.
For e.g., I have the tables test and test1.
create table test (a1 varchar(10), a2 varchar(10), a3 varchar(10), a4 date, a5 number, a6 number, a7 number, a8 number);
create table test1 (a1 varchar(10), a2 varchar(10), a3 varchar(10));
insert into test1 values('abc', 'a', 'z');
insert into test1 values('xyz', 'b', 'y');
insert into test values('abc', 'a', 'x', trunc(sysdate,'MM'), 100, 200, 300, 400);
insert into test values('abc', 'b', 'z', trunc(sysdate,'MM'), 567, 4778, 4234, 6767);
insert into test values('xyz', 'a', 'y', trunc(sysdate,'MM'), 5467, 2134, 5678, 8332);
insert into test values('xyz', 'b', 'z', trunc(sysdate,'MM'), 3534, 744, 678547, 46);
insert into test values('abc', 'a', 'x', trunc(add_months(sysdate,-1),'MM'), 700, 800, 900, 600);
insert into test values('abc', 'b', 'z', trunc(add_months(sysdate,-1),'MM'), 565477, 474578, 4456234, 226767);
insert into test values('xyz', 'a', 'y', trunc(add_months(sysdate,-1),'MM'), 235467, 2342134, 255678, 258332);
insert into test values('xyz', 'b', 'z', trunc(add_months(sysdate,-1),'MM'), 324534, 25744, 678547, 78846);
select * from test1;
A1 A2 A3
abc a z
xyz b y
select * from test;
A1 A2 A3 A4 A5 A6 A7 A8
abc a x 05/01/2010 00:00:00 100 200 300 400
abc b z 05/01/2010 00:00:00 567 4,778 4,234 6,767
xyz a y 05/01/2010 00:00:00 5,467 2,134 5,678 8,332
xyz b z 05/01/2010 00:00:00 3,534 744 678,547 46
abc a x 04/01/2010 00:00:00 700 800 900 600
abc b z 04/01/2010 00:00:00 565,477 474,578 4,456,234 226,767
xyz a y 04/01/2010 00:00:00 235,467 2,342,134 255,678 258,332
xyz b z 04/01/2010 00:00:00 324,534 25,744 678,547 78,846I have to write a query to get values for columns a1, a4, a5, a6, a7 and a8. For each distinct month fro mthe column a4, the values for columns a1, a4 a5 and a6 should be based on the condition test1.a1=test.a1 and test1.a2=test.a2. The condition for columns a7 and a8 should be test1.a1=test.a1 and test1.a3=test.a3.
How can I do this?
Thanks,
Machaanremove the 4th join and only duplicate test;
SQL> ed
Wrote file afiedt.buf
1 select distinct
2 case
3 when t11a1 is null then
4 t12a1
5 else
6 t11a1
7 end as a1
8 ,case
9 when t11a4 is null then
10 t12a4
11 else
12 t11a4
13 end as a4
14 ,case
15 when t11a5 is null then
16 t12a5
17 else
18 t11a5
19 end as a5
20 from (
21 select t11.a1 as t11a1
22 ,t11.a2 as t11a2
23 ,t11.a3 as t11a3
24 ,t11.a4 as t11a4
25 ,t11.a5 as t11a5
26 ,t11.a6 as t11a6
27 ,t11.a7 as t11a7
28 ,t11.a8 as t11a8
29 ,t12.a1 as t12a1
30 ,t12.a2 as t12a2
31 ,t12.a3 as t12a3
32 ,t12.a4 as t12a4
33 ,t12.a5 as t12a5
34 ,t12.a6 as t12a6
35 ,t12.a7 as t12a7
36 ,t12.a8 as t12a8
37 from test1 t1
38 ,test t11
39 ,test t12
40 where t1.a1 = t11.a1
41 and t1.a2 = t11.a2
42 and t1.a3 = t12.a3
43* )
SQL>
SQL> /
A1 A4 A5
xyz 01-APR-10 324534
xyz 01-MAY-10 3534
abc 01-APR-10 700
abc 01-MAY-10 100 -
Dynamic component in WHERE-condition for LOOP AT ?
i want to make
loop at itab where (dynamic field) > 0
how i can make it...
Edited by: Thomas Zloch on Mar 2, 2010 2:47 PMI thought it's funny.
And the problem can maybe be solved by using a completely dynamic where-condition, not just a dynamic component.
http://help.sap.com/abapdocu_70/en/ABAPLOOP_AT_ITAB_COND.htm#!ABAP_ADDITION_4@4@
Thomas
P.S. meaningless subject enhanced, and please take the time to say hi and please when asking for help. Thanks. -
Where condition for reading infotype while using ldb
hi
i want to read info from infotype p0000
using where condition eg: for pernr = ' '.
i am using LDB pnp.
how can i put the where condition while using macro
rp-provide-from-last.
regards
csin fact you don't have to get the values, you only need to tell to the program to take them into account :
GET PRPS.
CHECK SELECT-OPTIONS. -
Hi all,
Help me here when i try am unable to get a data,Can some one help me with a query to get.
If it cant be done can i know why..
select * from Sys.databases
where owner_sid='0x01'
What am trying is to get a login
names from syslogin
table with respect to Sid.
Select a.name,b.name,a.owner_sid from Sys.databases a
Join Syslogins b
on a.owner_sid = b.sid
where owner_sid like '0x01'
Thanks all in Advance.....Below are a couple of examples of how to accomplish the task. Note that SID is varbinary so the literal should not be enclosed in quotes.
SELECT
a.name AS DatabaseName
,b.name AS OwnerName
,a.owner_sid AS OwnerSID
FROM sys.databases a
JOIN sys.server_principals b ON
a.owner_sid = b.sid
WHERE owner_sid = 0x01;
SELECT
a.name AS DatabaseName
,SUSER_SNAME(owner_sid) AS OwnerName
,a.owner_sid AS OwnerSID
FROM sys.databases a
WHERE a.owner_sid = 0x01;
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
Case statement problem for a column in BMM layer
Hi friends.
In physical layer I've a "cardio" column whose data type is INT, and two values comes here either 0 or 1.
I need to replace 1 by 'YES' and 0 by "NO'.
For that I changed the datatype of "Cardio" column to CHAR. and in BMM layer I'm using this formula
CASE WHEN "A Analysis"."C Report"."CARDIO" = '1' THEN 'Yes' ELSE 'No' END
But this is giving me "Invalid Expression" error.
Please help me correct this error.
Help appreciated.Hi,
Your are probably using the column Cardio as a 'source' and as a 'target'.
So you have to duplicate the cardio column (right mouse click and Duplicate option) in the business model and then apply the formula CASE WHEN "A Analysis"."C Report"."CARDIO" = '1' THEN 'Yes' ELSE 'No' END
That should work. It is not even necessary to change datatype of Cardio, OBI will handle this for you.
Regards
Edited by: wobiee1 on Nov 12, 2008 1:07 PM -
Showing contents of a column based on a condition for another column.
Hello,
I am trying to create a report that lists all of the Opportunities within our database. I need a few details about this opportunity to appear. I need the account name that this opportunity belongs to, amongst other things- which I can do, however I also need to show the number of UNITS for this opportunity BUT I have a condition that needs to be met before I show the number of units.
I only want to show the UNITS IF the PRODUCTTYPE that this opportunity belongs to is "GA". Then I also need another column with UNITS in it, but again I only want the UNITS to appear if the PRODUCTTYPE IS DA.
Essentially I am trying to find out the number of units per product type and I need these to appear in separate columns. If the PRODUCTTYPE doesn't meet the condition, i.e. the PRODUCTTYPE is not GA then I would like the field to be blank.
I know that I should write this formula in the "Edit Formula" of the UNITS field, but I do not know how to write this condition.
I would very much appreciate some help as soon as possible.
Kind Regards,Hi,
You need to use a case statement, it looks like this:
CASE
WHEN opportunity.producttype = 'GA'
THEN opportunity.units
ELSE NULL
END
Ofcourse you need to use the correct column names.
Regards, Tim -
How to use MONTH NAME in where condition in date column?
Hi dudes,
this is the table.
sql>desc ACMINUTESPDFTEST;
Name Null? Type
ACDATE DATE
TYPES VARCHAR2(10)
here i have tried the following 2 queries,but i could not get the correct result
select types,seqno,acdate from ACMINUTESPDFTEST where acdate like to_date('NOV','MON');
or
select types,seqno,acdate from ACMINUTESPDFTEST where acdate = to_date('NOV','MON');
(for both the query the output is same)
TYPES ACDATE
PINK 01-NOV-10
but the table having following data:
TYPES ACDATE
PINK 14-NOV-10
WHITE 15-NOV-10
PINK 01-NOV-10
Any suggestion why i could not get correct result.bharathit wrote:
Thanks for toon and divya...it solved my problem and my question how will you select between two months..
select types,acdate from ACMINUTESPDFTEST where to_char(acdate,'MON') >= 'SEP' AND to_char(acdate,'MON') <= 'OCT';
and i got
no rows selected
Edited by: bharathit on Nov 2, 2010 10:37 PMIf you're interested in finding dates in a range of months regardless of the year then try this:
select ...
from ...
where to_number(to_char(date_column,'MM')) Between 9 And 10;You could also do something like:
select ...
from ...
where to_number(to_char(date_column,'MM')) In (1,4,7,10);If you are interested in dates in a range of months in a particular year however, use something like this:
select ...
from ...
where date_column >= date '2010-09-01' and
date_column < date '2010-11-01' and -
Only key fields of table-cluster in where-condition for better performance?
Hi,
Say my cluster table is having following key fields: KEY1, KEY2, KEY3, KEY4.
And, my table-cluster is having following key fields: KEY1, KEY2, PAGENO .. [PAGENO is always there in a table-cluster].
Now, I have two versions of my (Open SQL) SELECT-WHERE clause:
a) SELECT *
WHERE KEY1 EQ LV_KEY1
AND KEY2 EQ LV_KEY2
AND KEY3 EQ LV_KEY3.
b) SELECT *
WHERE KEY1 EQ LV_KEY1
AND KEY2 EQ LV_KEY2.
Please guide me whether version (a) or version (b) will be executed faster? In case of version (b), I will have to filter data using ABAP code corresponding to KEY3.
Regards,
Kamlesh Dhera H. R.I think most experienced ABAPrs would tell you to try both, compare runtimes, and use the one that's more efficient. SAP provides "get run time field <fieldname of type i>. Get run time at start, get run time at end, and subtract start from end to get the time in microseconds (1 second / 1,000,000 ).
Run several times to minimize effect of buffering and system load activity, and you'll see which method produces lower run time. -
Dynamic length-input in a where condition for a itab-attribut
Hi,
i want to loop from a itab in a dynamic way:
NOT Dynmaic:
loop at itab into wa where attribute1(5) = attribute2.
endloop.
Dynamic:
loop at itab into wa where attribute1(p_parameter) = attribute2.
endloop.
Unfortunately the syntaxcheck send me the following message if i try to use that code:
'The lengthinput 'p_parameter' ist not a numeric literal nor a numeric constant.'
What can i do?Hi,
Now i understood your problem.
You can try this work around
DATA:it TYPE TABLE OF mara,
wa TYPE mara.
DATA:r TYPE RANGE OF matnr.
DATA:w LIKE LINE OF r.
PARAMETERS:p_i TYPE i.
w-sign = 'I'.
w-option = 'CP'.
w-low+p_i(*) = '*'.
w-low+0(p_i) = 'ABC'. "Pass you attribute2 here
APPEND w TO r.
START-OF-SELECTION.
SELECT * FROM mara INTO TABLE it UP TO 10 ROWS.
LOOP AT it INTO wa WHERE matnr IN r.
ENDLOOP. -
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.. -
How to pass where condition to report for condition
hello people ,
i want to pass where condition for the report statement .
for example ,
select ename from emp
i want to pass parameter carry <where deptno=40>
thanksGood Morning oracleuser,
If we understood correctly, Bind references (or bind variables) should use this issue.
a>select ename from emp where deptno= :Dept_Number
If you have any more questions, please post it.
Otherwise:
Mark Helpful or Answer accordingly. -
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
) -
XML Report - Conditionally showing a column in between other columns
I have a XML Report, with columns
A, B, C, D
Now I need to add a new column E in between B and C when certain condition is satisfied.
A, B, E, C, D
for column E, I kept <?if:column='X'?> columnname <?endif?>.
When condition is satisfied it is displaying column and also values, but when not an empty column is displayed with no values, I dont want this empty column when condition is not satisfied.
It should just show A, B, C, D instead of A, B, , C, D
Request you to help me with my requirement.Hi Kavipriya, thanks for response.
I tried below condition for that column:
<?if@column:OM_Due_Date_X='Y'?> <?OM_Due_Date_L?> <?end if?>
I am setting OM_Due_Date_X in sql package to 'Y' if customer is 'Rob' else it will be 'N'.
If 'Y', then I am displaying a column name OM Due Date which is <"OM_Due_Date_L?>
Now for Column values it is just <?OM_Due_Date?>
Do I need to change anything here ?
Maybe you are looking for
-
History I have recently had to reinstall my OS Snow Lepoard. When restoring I found iphotos 9 would not reinstall due to corruption. Scenario I have now bought Ilife 11 with iphoto 11 on as I decided now would be a good time to upgrade. After install
-
Oracle 10g Enerprise Manager on Red Hat Enterprise 3.0
I am installing Enterprise manager with a new database and using all defaults. I get an error when the HTTP Server is being installed stating that it can not connect to http://atla-oms-db1:1830/em/main. Can anyone tell what could be wrong? Thanks!!!
-
"Program Error" on PS CS3 start up
Hi, I just downloaded an Apple Security update ["Security Update 2010-003" (1.0)] AND downloaded the Acrobat and Reader updates. Both of the updates installed properly. Now Photoshop CS3 on my Intel iMac AND PowerPC G5 tower will not complete startup
-
Water spilled on the screen - what to do?
I was checking something last night on my macbook when my kid smacked the water in the bathtub and splashed my macbook. I turned it upside down and shook it to get the water out, wiped what was on the keyboard and it seemed ok. There was a little bri
-
Cancel iCloud storage plan from 20.0 cost $ 0.99 to 5GB cost free
I Have a iPhone 5s last week but how can I cancel my iCloud storage plan from 20.0GB cost $ 0.99 to 5GB cost free ssomeone tell me because I don't want to pay the bill