How to use many conditions in query

Hi all,
i have a situation,must prepare a report to find availability of it devices.they are given the specific ip of devices.
my query
SELECT 
 Resultdate, [SERVICE]  ,[SERVICE TYPE] ,[IP]
, DailyAvailability
  FROM [Orion].[dbo].[DepartmentNodesNew] t1
left join (   select round(1-(sum([DownTimeMin])/(1440*count(*))),4)*100  as DailyAvailability,
  count(*) as Node,   c2.ResultDate  ,[Departament]  ,[IPAdress]
   from  [Orion].[dbo].[OrionEventsNodeDownTime] as c2 group by  [Departament] ,[IPAdress] , c2.ResultDate) t2
   on t1.IP=t2.IPAdress 
   where t2.DailyAvailability is not null and t1.SERVICE='SAP CRM' and t2.ResultDate='2014-12-10'
    order by ResultDate
now how can i calculate the daily availability of sap crm which have 2 servers and they are in cluster,when one is down service is ok.when both of them are down service is off. how can i calculate by writing conditions.
 case when  ([SERVICE]='SAP CRM' AND [SERVICE TYPE]= 'DB Server' and [DownTimeMin] =0) then DBAvailability 100
  else  then DBAvailability select round(1-(sum([DownTimeMin])/(1440*count(*))),4)*100 ???

SELECT Resultdate
,[SERVICE]
,[SERVICE TYPE]
,[IP]
,DailyAvailability
INTO #TempTable
FROM [Orion].[dbo].[DepartmentNodesNew] t1
LEFT JOIN (
SELECT round(1 - (sum([DownTimeMin]) / (1440 * count(*))), 4) * 100 AS DailyAvailability
,count(*) AS Node
,c2.ResultDate
,[Departament]
,[IPAdress]
FROM [Orion].[dbo].[OrionEventsNodeDownTime] AS c2
GROUP BY [Departament]
,[IPAdress]
,c2.ResultDate
) t2 ON t1.IP = t2.IPAdress
WHERE t2.DailyAvailability IS NOT NULL
AND t1.SERVICE = 'SAP CRM'
AND t2.ResultDate = '2014-12-10'
ORDER BY ResultDate
SELECT Resultdate
,[SERVICE]
,[SERVICE TYPE]
,[IP]
,DailyAvailability
,CASE
WHEN (
[SERVICE] = 'SAP CRM'
AND [SERVICE TYPE] = 'DB Server'
AND [DownTimeMin] = 0
THEN 100
ELSE round(1 - (sum([DownTimeMin]) / (1440 * count(*))), 4) * 100
END AS 'DBAvailability'
FROM #TempTable
-Vaibhav Chaudhari

Similar Messages

  • What is the use of Condition is Query Designer  ??

    What is the use of Condition in Query Designer  ??
    How to use condition in   Query Designer  ??

    Hi,
    Conditions in a query can be defined for both characteristic combinations and key figures.
    Characteristic combinations can be used using the ranking list functionality (e.g Top N or Last N customers with highest sales).
    Key figures can be assigned the value limit conditions ( for e.g. display only rows in the query for which the key figure > 10 ).
    For your specific requirements in which you need to display only a limited set based on the key figures, then you can go for conditions.
    The conditions can be allowed to work on all the drill down characteristics independently, single characteristics or combination as well based on your requirement.
    While execution the report, you can activate or deactivate the condition anytime by right clicking on the data cells.
    Regards,
    VA

  • How to use the same POWL query for multiple users

    Hello,
    I have defined a POWL query which executes properly. But if I map the same POWL query to 2 portal users and the 2 portal users try to access the same page simultaneously then it gives an error message to one of the users that
    "Query 'ABC' is already open in another session."
    where 'ABC' is the query name.
    Can you please tell me how to use the same POWL query for multiple users ?
    A fast reply would be highly appreciated.
    Thanks and Regards,
    Sandhya

    Batch processing usually involves using actions you have recorded.  In Action you can insert Path that can be used during processing documents.  Path have some size so you may want to only process document that have the same size.  Look in the Actions Palette fly-out menu for insert path.  It inserts|records the current document work path into the action being worked on and when the action is played it inserts the path into the document as the current work path..

  • How to use if condition in XML Publisher Desk Top

    Hi..,
    How to use if condition in XML Publisher desk Top.
    Please guide me.
    Thanks,
    Suresh.

    What kind of condition you want to use?
    You can use Condition like this:
    <?xdofx:if condition then value1
    else if condition then Value2
    else Value3
    end if?>
    Please go thru XML Publisher User Guide.
    Thanks
    Ravi
    [email protected]

  • How to use Key Date in query

    Imagine an invoice was created for a customer on the 1st of January 2008 for £1000
    On the 1st of Feb, he paid $300, owing $700
    On the 1st of Mar, he paid $450, owing $250
    On the 1st of Apr, he paid $250.
    If I run an AR report today the 10th of Aug, I would see he owes nothing. What I want to do is to run the report today based on the 2nd of March and see a debt of £250. I dont want to use the posting date in the selection criteria henceI think this is the case when you use a key date but I’m not sure how to use this in the query properties of BI7. What Characteristic do I need to specify as time dependant? Is there anything else I should consider?

    hi,
    Key Date setting is for the 'time dependent' master data.
    Lets say u have a Characteristic MATERIAL with a time dependent attribute MATERIAL GROUP as follows.
    MATERIAL FROM TO MATERIAL GROUP
    ABD 01/01/1995 12/31/2003 X
    ABD 01/01/2004 12/31/9999 Y
    Depending on what you have for the Keydate, the Material group is selected.
    If your key date is, ex, 06/12/2001 there material group is X. Or if key date is 02/15/2005, material group is Y.
    If you do not enter any value for keydate, system automatically assumes today' date.
    hope it helps..

  • How to use upload condition record program RV14BTCI

    Hi
    how to use upload condition record program RV14BTCI.
    kathir.

    Hi,
    To run this program we have to maintain Upload file in Application Directory,
    We have to maintain 3 levels of records in that file.. my feel you upload through BDC or LSMW.
    For your information,
    The batch input program RV14BTCI reads the parameters is necessary
    Giving sequential file and creates (depending on the data
    In the file seq) one or more batch input sessions.
    The data are seq file in the following structure expected:
    - The session a session intent (Table KOBTCI, Record 0)
    All other records until the next session, the intent
    Last session assigned to read
    - The head condition Sentence (Table KOBTCI, record 1)
    All other records until the next condition,
    Last read head appropriate rate
    This includes the corresponding condition
    Condition table
    - The key sentence of a Main (Table KOBTCI, record 2)
    It must be directly on the head set to follow
    It contains the key condition of the table
    + Detail fields
    - The season record has a subordinate clause (Table KOBTCI, record 3)
    The teams relate to the key sentence in the main
    Best Regards,
    KSK

  • 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 T

    Do 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

  • How to Use MAX condition using Query Report

    Hi SAP Abap Expert,
    Can we use the MAX condition in Query Report (SQ01/SQ02) ?
    I have created one sample query using table VBRP and VBRK then i need to use max condition to get the MAX record in VBELN.
    Please Help ???

    Hi Ashishsingh,
    According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
    http://technet.microsoft.com/en-us/library/ms145601.aspx
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to use Results from Another Query for SAP BW universes

    Hi Everyone,
    I have two SAP BI universes.In my First universe I have Sales Doc no (dimension) and Orderqty (Measure) and in my second universe I have Sales Doc no(Dimension) and BillQty (Measure).
    Here in my first dataprovider I have 1200 rows of data and in second dataprovider I have 75,000 rows. The report should fetch only the BillQty details that matches to corresponding  Sales doc no in first data provider.
    I want to place all these fileds into a single report like as shown.
    (Datarpovider1)                (Datarpovider1)                    (Datarpovider2)
    *Sales Doc No*               Orderqty                           BillQty
    Here I am able to generate single report using merge dimension but it is leading to performance issues. I want to restrict the values at query level by passing the First dataprovider Sales doc no to second Data provider Sales doc number using Results from Anothery Query feature so that It can fetch only the matching records.
    I tried it but it was giving the follwing error:
    A filter contains a wrong value. You cannot run this query. (Error: WIS 00007)
    How Can I get rid of this error. Can we use Results from Anothery Query option for OLAP universe. Are there any limitation on it.
    All this I am doing in Webi Rich Client.
    Appreciate your help
    Thanks &in Advance
    Kiran Saka

    Hi Kiran,
    I think the filter has a wrong operand. For example, a filter with an empty constant, or a filter that deals with numeric values is defined with an alphanumeric value.Check out for this.
    Regards,
    Neeraj

  • How to use the not exists query

    Hello,
    Using obiee 11g,
    i would like to know how to deal with not exists query in the obiee11g,
    the query is like this
    select count(a.col1),a.col2 from table1 a ,table2 b where a.col1=b.col1
    and not exists
    (select d.col1 from table3 d, table4 e
    where d.col1=e.col1 and d.col1=a.col1)
    group by a.col2
    there are 4 tables.
    table1,table2,table3,tabel4
    this is what i need in a report,these tables are used in othere places also,
    would prefer if its possible to do in for a report i.e.e analysis itself.
    If not possible then may be in rpd since if i change in rpd it may reflect every place
    and not in for a report itself.
    thanks

    Implement this in report itself can be a tricky and tedious job..But better to have it in RPD - Physical - Select Table type
    USE NOT IN in place of NOT Exist..You can simply use SELECT statement in SELECT TABLE TYPE
    Hope it clear

  • How to use property file - sql query define in property file

    Hi All,
    Anybody please tell me how to use property file.
    I have placed sql query in propery file and I have to access this in my file.
    well so far this is my code but don't know how to implement in the following ...
    pstmt = con.prepareStatement("select * from registration where username=?");
    instead of writting the query I want to use the property file.
    so far I have developed the following code...
    FileInputStream fis = new FileInputStream("querysql.property");
    Properties dbProp = new Properties();
    dbProp.load(fis);is the code correct... or is there another way to access property file
    Please help.
    please reply soon....
    Thanks

    Before answering, check if it's already been done here http://www.jguru.com/forums/view.jsp?EID=1304182

  • How to Use dyanamic table in query?

    Hi,
    can you please tell.in query -
    1] if we define a varibale and in that varibale we have to speacfy the dynamic table name can it's possible.
    2] I tried but it's not working
    3] Every year i have taken a backup table and from that backup table i feteched the data.But i want to do this programmatically
    e.g. Table name is pf_emp_pf_txn20122013 but this is "20122013" this dynamic .How we use in query that dyanamic table .
    Kindly Suggest,
    Regards,
    Sachin

    RHELSENSEI wrote:
    Your EXEC executes in a different context, therefore it is not aware of any variables that have been declared in your original context. You should be able to use a temp table instead of a table variable as shown in the simple demo below.
    create table #t (id int)
    declare @value nchar(1) set @value = N'1' 
    declare @sql nvarchar(max)
    set @sql = N'insert into #t (id) values (' + @value + N')'
    exec (@sql)
    select * from #t
    drop table #t
    Epic. Fail.
    SQL-Server syntax and features for an Oracle problem. Features that are not relevant at all to Oracle, but the very reason why SQL-Server is technically inferior to Oracle...
    Are you a professional idiot, or just a very gifted amateur?

  • How to use moving maximum in query desighner

    Hi All,
    i am new to BI, please help.
    I have a requirement to find the maximum and minimum posting date for an article.
    For this i would need to use the moving maximum feature of the query. where to find this function and how to use it.
    please reply
    thanks,
    kushagra

    Hi,
    Max/Min functions can't be applied on characteristics. I'm not sure but you can try using a formula variable or exception aggregation.
    --Akashdeep

  • How to use output of one query as an input for another

    Hi Gurus,
    can you give me any links on how to use an output of one query as an input for another (preferably if this can be done in a dynamic/on the fly way)?
    thanks

    You can use Replacement Path Variable for this purpose. See this detailed documentation.
    http://help.sap.com/saphelp_nw04s/helpdata/en/bd/589b3c494d8e15e10000000a114084/content.htm
    Abhijit
    Edited by: ABHIJIT TEMBHEKAR on Nov 19, 2008 9:48 AM

  • How to use "where" condition when we use update or delete in a dbadapter?

    Hi
    I want to update/delete a record in a database table based on one of its fields. Which means I have to use "where" condition to check the value of the field and only then I can decide whether or not the record can be updated/deleted.
    When I try to use the dbadapter update/delete options, I dont see any provision for writing the "where" condition.(May be I am missing something).
    I know that I can use the custom sql option and write an sql command to achieve this.
    But I would like to know if this can be done when using the update/delete option itself in the dbadapter.
    Thanks in anticipation.
    Ravi

    Hi,
    You can use the logical delete option. In that case you can supply a value for the column that indicates if a record is changed and have it picked up by the db adapter.
    Andre

Maybe you are looking for