Looking to write a query to give me the missing numbers in a sequence
My query here gives me a list of numbers:
select distinct cast(SUBSTRING(docket,7,999) as INT) from [DHI_IL_Stage].[dbo].[Violation] where InsertDataSourceID='40'
and ViolationCounty='Carroll' and SUBSTRING(docket,5,2)='TR' and LEFT(docket,4)='2011'
order by 1
Gives back:
I want to find the numbers missing in the sequence
CREATE TABLE t1 (C INT NOT NULL PRIMARY KEY)
insert t1 select 1 union all
select 3 union all
select 4 union all
select 5 union all
select 7 union all
select 10
SELECT
c+n FROM t1, (
SELECT 0 n UNION ALL SELECT 1
) T
GROUP BY c+n
HAVING MIN(n) = 1 and c+n < (select max(c) from t1)
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Similar Messages
-
How do I write a query to give back the records only with today's date?
For example the date format is "2014-05-01 16:31:35.897" is a column called "EffectiveStartDate'
I tried using where EffectiveStartDate like '2014-05-01%' but that returns nothing.This is not a good suggestion from Chuck although normally he provides very good responses. I unmarked that response.
Please read this article by Aaron Bertrand:
http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/16/bad-habits-to-kick-mishandling-date-range-queries.aspx
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Which table will give me the serial numbers per each delivery?
Which table will give me the serial numbers per each delivery?
Hi,
Table:
SER01 -> provide links between delivery and serial number object.
You can select by LIEF_NR = 'delivery number'.
OBJK -> content of serial numbers
You can select by OBKNR = 'SER01-OBKNR'.
Further more:
You can check in SE11 with name "SER0*". Then you can see a list of tables which contains link between serial number to other document.
SER01 -> Delivery
SER02 -> Maint.Contract (SD Order)
SER03 -> Goods Movements
SER04 -> Inspection Lot
SER05 -> PP Order
SER06 -> Handling Unit-Content
SER07 -> Physical Inventory
SER08 -> Purchase Order Item Serial Numbers
Regards,
Harry -
How to write a query for grouping them the columns and give the sequence order to each group/
Hi i have table that contains country columns .
India,USA,UK like these when ever the group changed into the differt country i make a group and arrange them the sequence into those Countries
like below
1)India
2)India
1)USA
2)USA
like these to write a query ..........pls help me for this queryAssuming you're using SQL Server you can ask here:
http://www.sqlteam.com/forums/forum.asp?FORUM_ID=23
Otherwise, please ask in the relevant forum for the type of technology you're using.
Basically it's either:
select *
from [table name]
order by country
If you want to do something with groups do something like:
select (max) income, country
from [table name]
group by country
Kind regards,
Margriet Bruggeman
Lois & Clark IT Services
web site: http://www.loisandclark.eu
blog: http://www.sharepointdragons.com -
Looking for a SQL query to get all the possible Alert Messages from the Rules in a Management Pack
For reporting, I'm looking to get a SQL query of all the possible Alert Messages for Rules configured in a Management Pack (not necessarily the ones that have thrown alerts). I can do this for Monitors, but not for Rules.
The configured alert messages for the Management Pack Monitors
go like this: ManagementPack > MonitorView> RuleModule > RuleModule.Alert Message > Localized Text
The configured alert messages for the Management Pack Rules
should go something like this, but there is a missing link: ManagementPack > RuleView > RuleModule > ? Missing Link ? > Localized Text
The Rules are tied to the Module, but I don't see a connection from the RulesModule to the Alert Message that I see in the LocalizedText. The Rule names do not always equal the Alert name.
Can someone provide the missing link?Hi,
please try below powershell code to find the corresponding management pack for specific alert:
$Alert = get-scomalert | where {$_.Name -like 'Agent Proxy Not Enabled*'} | select -first 1
If ($alert.IsMonitorAlert -eq "True") {
write-host "Ths is a monitor-generated alert"
get-scommonitor -ID $Alert.MonitoringRuleID | select Enabled, DisplayName, ManagementPack
else
write-host "This is a rule-generated alert"
get-scomrule -ID $Alert.MonitoringRuleID | select Enabled, DisplayName, ManagementPack
In addition, please also refer to the below link:
http://blogs.technet.com/b/mazenahmed/archive/2011/12/02/using-powershell-to-map-opsmgr-active-alert-to-its-corresponding-rule-monitor-and-management-pack-name.aspx
Regards,
Yan Li
Regards, Yan Li -
How to write a Query a table and the return result is the column name
Hi All
Pls advise how to write a query whereas the return result is the
column name.
I know there is describe <table_name>;
Is there any other ways?
Pls advise
Tj
Edited by: user600866 on Oct 14, 2008 12:13 AMData Dictionary table user_tab_columns has all the column names. You can query that and get what ever you want.
To get the column list of a table just query
select *
from user_tab_columns
where table_name = <your_table>Edited by: Karthick_Arp on Oct 14, 2008 12:18 AM -
Hello, I have just done a download of the new iPhone software and I am still having an issue with not being able to connect to WiFi or BlueTooth. Both of these under my settings are grayed out, so I have no option to even turn them on. Does anyone know what I can do to fix this issue.
ThanksSee: http://support.apple.com/kb/TS1559
If this doesn't resolve the problem you have a phone with a hardware failure. -
Urgent Query please give me the solution ASAP
Hi ,
i want to know a simple thing,and my question is "How we can retrive data from a database table using BPEL ,e.g emp"
if possible plesae tell me the step by step process.
Thanks ,
PrakashHi Prakash,
In order to retrieve data from a database table u will have to do the following
1- Create a Database connection on ur Database according to it's type.
2- Select the Services tab from the component palette.
3- Drag and drop a Database adapter.
4- A wizard window will open type in the service name for example select then choose the DB connection u created in step 1 then select the perform an operation on the table then select (select) radio button then import the table u want to select from , enter selection coloumns u want to add then finish.
5. Now you have created the Database adapter u need an invoke activity and create a variable that will hold this data using ur table schema . -
Help to write a query for cursor
Hi
I have a table trans_table which has records for all Credit (C) and Debit(D) entries for customers with the trans_date.
Now there is a column adj_amt which contains 0 for all D entries. But for C entries it contains current trans_amt - Prev trans_amt. If there is no prev record with C type then it is 0. i.e. If this the first C entry for a particular account then adj_amt will contain 0.
Below is the data.
create table trans_table (cust_id number, tran_date date, tran_amt number, tran_type char(1), adj_amt number);
1 01/01/2007 100 D 0
1 01/01/2007 100 D 0
1 01/02/2007 80 C 0
1 05/02/2007 200 C 120
1 08/02/2007 300 C 100
2 01/01/2007 100 D 0
2 05/01/2007 100 D 0
2 08/01/2007 100 D 0
2 09/01/2007 100 D 0
2 01/02/2007 90 C 0
2 05/02/2007 200 C 110
3 01/01/2007 100 D 0
3 05/01/2007 100 D 0
3 08/01/2007 100 D 0
4 01/01/2007 100 D 0
4 05/01/2007 100 D 0
4 06/01/2007 100 D 0
4 08/01/2007 100 D 0
4 10/01/2007 100 D 0
4 01/02/2007 100 C 0
Now hv to write a query whioch gives the cust_id , max(tran_amt) with D entry, max(trans_amt) wth C entry and if no C entry record then this column will be 0.
The output wud be klike this..
1 100 300
2 100 200
3 100 0
4 100 100
Since cust_id 3 has no C entry so 0 value in 3rd column.
Now i wrote a query for cust_id and 2nd column, but am not able to get the 3rd column.
Is it possible to get the above output..
I wud be using this query in a cursor which wud fetch from 20 million transactions.
Thanks in advance
Piks
(I am pasting the insert script if required)
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (4, to_date('01-02-2007', 'dd-mm-yyyy'), 100, 'C', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (4, to_date('05-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (4, to_date('01-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (4, to_date('10-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (4, to_date('08-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (4, to_date('06-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (3, to_date('08-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (3, to_date('05-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (3, to_date('01-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (2, to_date('05-02-2007', 'dd-mm-yyyy'), 200, 'C', 110);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (2, to_date('01-02-2007', 'dd-mm-yyyy'), 90, 'C', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (2, to_date('05-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (2, to_date('01-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (2, to_date('09-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (2, to_date('08-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (1, to_date('08-02-2007', 'dd-mm-yyyy'), 300, 'C', 100);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (1, to_date('05-02-2007', 'dd-mm-yyyy'), 200, 'C', 120);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (1, to_date('01-02-2007', 'dd-mm-yyyy'), 80, 'C', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (1, to_date('01-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);
insert into TRANS_TABLE (CUST_ID, TRAN_DATE, TRAN_AMT, TRAN_TYPE, ADJ_AMT)
values (1, to_date('01-01-2007', 'dd-mm-yyyy'), 100, 'D', 0);Hitherto an attempt:
test@ORA92>
test@ORA92> select * from trans_table;
CUST_ID TRAN_DATE TRAN_AMT T ADJ_AMT
4 02/01/2007 00:00:00 100 C 0
4 01/05/2007 00:00:00 100 D 0
4 01/01/2007 00:00:00 100 D 0
4 01/10/2007 00:00:00 100 D 0
4 01/08/2007 00:00:00 100 D 0
4 01/06/2007 00:00:00 100 D 0
3 01/08/2007 00:00:00 100 D 0
3 01/05/2007 00:00:00 100 D 0
3 01/01/2007 00:00:00 100 D 0
2 02/05/2007 00:00:00 200 C 110
2 02/01/2007 00:00:00 90 C 0
2 01/05/2007 00:00:00 100 D 0
2 01/01/2007 00:00:00 100 D 0
2 01/09/2007 00:00:00 100 D 0
2 01/08/2007 00:00:00 100 D 0
1 02/08/2007 00:00:00 300 C 100
1 02/05/2007 00:00:00 200 C 120
1 02/01/2007 00:00:00 80 C 0
1 01/01/2007 00:00:00 100 D 0
1 01/01/2007 00:00:00 100 D 0
20 rows selected.
test@ORA92>
test@ORA92> select
2 cust_id,
3 max(case when tran_type = 'D' then tran_amt else 0 end) as max_c,
4 max(case when tran_type = 'C' then tran_amt else 0 end) as max_d
5 from trans_table
6 group by cust_id;
CUST_ID MAX_C MAX_D
1 100 300
2 100 200
3 100 0
4 100 100
4 rows selected.
test@ORA92>
test@ORA92>Cheers
pratz -
Calling SQL experts to help write a query
Trying to find some help from some sql experts.
I was asked to help write a query showing each Dialed_Number, the associated Call_Type, and Script(s) in an ICM configuration.
All the data I’m looking for seems to be in the following tables:
Dialed_Number (DialedNumberString, EnterpriseName, DialedNumberID)
Call_Type (CallTypeID, EnterpriseName)
Dialed_Number_Map (DialedNumberID, CallTypeID)
Call_Type_Map (CallTypeID, MasterScriptID)
Master_Script (MasterScriptID, EnterpriseName)
Thus far, my query looks like this:
SELECT distinct Dialed_Number.DialedNumberString, Dialed_Number.EnterpriseName AS DN_Name, Call_Type.EnterpriseName AS Call_Type_Name,
Master_Script.EnterpriseName AS ScriptName
FROM Call_Type_Map CROSS JOIN
Call_Type CROSS JOIN
Dialed_Number CROSS JOIN
Dialed_Number_Map CROSS JOIN
Master_Script
However, it’s returning every possible combination (it was 10x worse before adding the word ‘distinct’)
Ideally, I’d like the results to just show one row for each Dialed_Number (assumes 1:1 ratio of DN to CallType).
e.g.:
DN_Name DialedNumberString CallType_Name ScriptName
Can anyone offer any guidance or suggestion?Thanks Geoff,
I'd put this out on a couple different channels, and while yours is pretty good (I did remove the RoutingClientID from the where clause), I got another version that works just as well, and also includes DNs without CallTypes, and those which may have a CallType, but no script.
SELECT dn.DialedNumberString, dn.EnterpriseName AS Dialed_Number_Name, ct.EnterpriseName AS Call_Type_Name, ms.EnterpriseName AS Script_Name
FROM Dialed_Number dn
LEFT OUTER JOIN Dialed_Number_Map dnm ON dn.DialedNumberID = dnm.DialedNumberID
LEFT OUTER JOIN Call_Type ct ON dnm.CallTypeID = ct.CallTypeID
LEFT OUTER JOIN Call_Type_Map ctm ON ct.CallTypeID = ctm.CallTypeID
LEFT OUTER JOIN Master_Script ms ON ctm.MasterScriptID = ms.MasterScriptID
I believe the "joins" are supposedly more efficient, too.
Thanks for your contribution! -
How should i write a query for this?
Hi i give the follwing query to implement the result,
IT will gives you the result of one country machines information like Total machines failed machines and success machines of their count
Countyr Name CountryCode Total Machines Failed Machines and Succes machines and their perentage
IT ITALY
1000 20
980 98%
like these i want to display the 16 countyr machines information all country information in one palce like table format
i will give you the query to the below here it is the combination of powershell code also used here with sql code.
Code as Country
Name as Country
And below i mentioned OU in bold every where i will put the country code according to the country
like OU=FR
Select
'FR' as 'Code',
'FRANCE' as 'Name',
(select COUNT(*) from ADComputersInfo where
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
(select COUNT(*) from ADComputersInfo where
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
(select COUNT(*) from ADComputersInfo where
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
(select COUNT(*) from ADComputersInfo where
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
(select count(distinct(cn)) from ADComputersInfo where
(ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
and cn in (select name0 from v_R_System)
(select count(distinct(cn)) from ADComputersInfo where
(ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
and cn not in (select name0 from v_R_System)
select count(distinct(cn)) from ADComputersInfo where
(ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
and cn in (select name0 from v_R_System where Client0 =1 and Obsolete0 =0)
select count(distinct(cn)) from ADComputersInfo where
(ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
and cn not in (select name0 from v_R_System where Client0 =1 and Obsolete0 =0)
So here i pass the County code and country name and OU=FR(assigned country code )
so hw we can all these 3 values in all the query can give me the r8 query for this . And i will get the all 16 country information
Ineed exact query hw we can implement..........................................
I might be excepting lot from our side guys...
Thanks !
AdvancedHi
Can you simple post sample data + desired result? Always state what version you are using..
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Need query to find out the sum till a period
Hi,
I need to write one query to find out the cumulative sum of raw_cost of table pa_budget_lines till the specified period, I tried to do this by analytical function, but that is not working in Report 10g. Can anybody help me in this.
Thanksnot familiar with report but could you do something like this
with t as
select 1 grp, 10 * level the_cost, add_months (sysdate, level) effective_dt from dual connect by level < 11 union all
select 2 grp, 5 * level the_cost, add_months (sysdate, level) effective_dt from dual connect by level < 11
input as
( select null grp, null the_cost, null running_total, v_eff_dt effective_dt from dual)
select * from(
select t.grp, t.the_cost, sum(t.the_cost) over (partition by t.grp order by t.effective_dt) running_total, t.effective_dt,
lead(t.effective_dt) over (partition by t.grp order by t.effective_dt) next_effective_dt,
input.effective_dt inp_eff_dt
from t, input
where inp_eff_dt between effective_dt and next_effective_dtv_eff_dt would be the input date you are interested in -
Query Designer, Execute fails with missing iView (Portal Runtime Error)
Hi,
I have followed all steps to integrate Sap NetWeaver 2004s BI into EP. Checks done so far indicate that all is well between the EP and BI. From within the EP, I can execute the Bex Web Analyser iView and from there I can execute a query on the BI backend. From the BI backend, executing the function module RSWR_RFC_SERVICE_TEST returns the 'BI test service' success message. SSO is working fine as no user/passwords were prompted for. From the trace file, I can see no errors appear but I do see authentication success messages. So far, so good
But, when I execute a query from within the Query Designer, it calls the browser and then errors with the following error:
<b><i>Portal Runtime Error
An exception occurred while processing a request for :
iView : N/A
Component Name : N/A
iView not found: pcd:portal_content/com.sap.pct/platform_add_ons/com.sap.ip.bi/iViews/com.sap.ip.bi.bex.
Exception id: 10:06_03/03/06_0012_26285450
See the details for the exception ID in the log file</i></b>
Looking at the trace file, all it tells me is the same, that this iView is not found.
If I logon to the portal and have a look at the iViews within the 'platform-add-ons/bi' folder, I can see the following 4 iViews:
BEx Broadcaster (com.sap.ip.bi.bexbroadcaster)
BEx Portfolio (com.sap.ip.bi.bexportfolio)
BEx Web Analyser (com.sap.ip.bi.bexwebanalyzer)
My Portfolio (com.sap.ip.bi.myportfolio)
I cannot find the missing iView (com.sap.ip.bi.bex).
Any ideas/suggestions would be appreciated.
Thanks in advance.Hi Ashish,
Thanks for the suggestions. Here is what happened:
1. I have run the deploy and change template again (BIPostInstall). Step 10 failed but I am not too concerned as it does appear that SSO is working both directions. Also, step 13 failed which is the 'Configure Repository Manager'. The error I got here was USER_AUTH_FAILED: User account for logonid "" not found. I am not sure where it is getting the blank userid from.
2. The 'com.sap.ip.bi.business_explorer_showcase' role suggestion looked very promising. I found some doco on it and it does mention this role and when assigned, then you see the Business Explorer tab. I assigned it to all users and to all groups. When I went back into the portal, sure enough, the Business Explorer tab was visible. From within there, I could run query which all worked fine.
BUT, when executing a query from within the BEx Query Designer, I still got the same error:
<i><b>Portal Runtime Error
An exception occurred while processing a request for :
iView : N/A
Component Name : N/A
iView not found: pcd:portal_content/com.sap.pct/platform_add_ons/com.sap.ip.bi/iViews/com.sap.ip.bi.bex.
Exception id: 11:25_05/03/06_0003_26285450
See the details for the exception ID in the log file</b></i>
Do you know if this is an actual iView that should exist in the portal content ? If you have this working, can you see this iView in the portal?
3. I had a look at this note (872043) but I could not get the sap download manager to work to get the zip files attached to the note download. If you have it still, could you email it to me ([email protected]) and I will try that. Did you apply the zip file?
I can't find any further trace information on why this missing iView error is happening. I've amended the severity level on the areas which a SAP note detailed but the only information I get is that a missing iView was called.
Function module RSWR_RFC_SERVICE_TEST still works fine and I can execute a query from the Web BEx Analyser iView.
I just can't execute a query from the BEx query designer due to the missing iView.
I don't know whether it is a communication problem even though SSO both directions seem to work OR whether I do have some content missing from my portal.
Regards -
A better way to write last_day query
Hi folks,
I am looking for a better way to write a query to find last_day in month but if its sunday or holiday it should move to day before last day.
So for example if 31 is sunday it should go for 30, if 30 is holiday it should move down to 29.
I got this so far but the connect by level is hardcoded to 15. Want to see if there is a better way to get this working:
select max(datum)
from ( select last_day(trunc(sysdate)) - level + 1 as datum
from dual
connect by level < 15)
where to_char(datum, 'day') != 'sunday'
and to_char(datum, 'DDMM') not in
('3012')Best regards,
IgorLike this
select to_char(last_day_month, 'Day') day_is,
last_day_month,
last_day_month - case when to_char(last_day_month, 'fmday') = 'sunday' then 1
when to_char(last_day_month, 'ddmm' ) = '3012' then 1
else 0
end last_business_day_month
from (
select last_day(add_months(trunc(sysdate, 'year'), level-1)) last_day_month
from dual
connect by level <= 12
DAY_IS LAST_DAY_MONTH LAST_BUSINESS_DAY_MONTH
Tuesday 31-JAN-12 31-JAN-12
Wednesday 29-FEB-12 29-FEB-12
Saturday 31-MAR-12 31-MAR-12
Monday 30-APR-12 30-APR-12
Thursday 31-MAY-12 31-MAY-12
Saturday 30-JUN-12 30-JUN-12
Tuesday 31-JUL-12 31-JUL-12
Friday 31-AUG-12 31-AUG-12
Sunday 30-SEP-12 29-SEP-12
Wednesday 31-OCT-12 31-OCT-12
Friday 30-NOV-12 30-NOV-12
Monday 31-DEC-12 31-DEC-12 -
Sql query ..need idea to write complex query
Hi there,
I have assigned the task to write a sql query to get the output as the below stored proc does.
In the proc conditions are given with IF statements. I really dont know how to give all the conditions for the period in a single sql query as I'm not much used to sql quries.
Is anyone could help me?
Any suggestions pls . writing complicated query is nightmare. no idea . if possible help me...
create or replace PROCEDURE vpp_station_summary_report (
in_user_id IN VARCHAR2,
in_report_id IN NUMBER,
in_time_from IN vppstation.avi_status_history.status_eff_date%TYPE,
in_time_to IN vppstation.avi_status_history.status_eff_date%TYPE,
result OUT SYS_REFCURSOR)
AS
CURSOR station_loop IS
SELECT ash.station_id,
ash.avi_id,
ash.state_id,
ash.state_eff_date
FROM vppstation.avi_state_history ash
JOIN vpproadside.vpp_report_stations
ON vpp_report_stations.station_id = ash.station_id
AND vpp_report_stations.vpp_report_seq_number = in_report_id
WHERE ash.state_eff_date BETWEEN in_time_from AND in_time_to
ORDER BY ash.station_id,
ash.avi_id,
ash.state_eff_date,
ash.ash_id;
-- cursor to find the 'entry state' i.e. the state the AVI was in AT the time of
-- in_time_from
CURSOR entry_state (
state_station_id vppstation.avi_state_history.station_id%TYPE,
state_avi_id vppstation.avi_state_history.avi_id%TYPE,
state_state_date vppstation.avi_state_history.state_eff_date%TYPE
IS
SELECT ash.state_id
FROM vppstation.avi_state_history ash
WHERE ash.station_id = state_station_id
AND ash.avi_id = state_avi_id
AND ash.state_eff_date < state_state_date
ORDER BY ash.state_eff_date DESC,
ash.ash_id DESC;
current_station_id vppstation.avi_state_history.station_id%TYPE;
current_avi_id vppstation.avi_state_history.avi_id%TYPE;
current_state_id vppstation.avi_state_history.state_id%TYPE;
current_state_eff_date vppstation.avi_state_history.state_eff_date%TYPE;
period_length NUMBER;
next_station_id vppstation.avi_state_history.station_id%TYPE;
next_avi_id vppstation.avi_state_history.avi_id%TYPE;
next_state_id vppstation.avi_state_history.state_id%TYPE;
next_state_eff_date vppstation.avi_state_history.state_eff_date%TYPE;
station_open_total NUMBER;
station_closed_total NUMBER;
station_all_report_total NUMBER;
current_station_name vpproadside.vpp_station_summary.station_name%TYPE;
state_open vppstation.avi_control_state_code.state_id%TYPE;
state_closed vppstation.avi_control_state_code.state_id%TYPE;
state_all_report vppstation.avi_control_state_code.state_id%TYPE;
BEGIN
SELECT state_id
INTO state_open
FROM vppstation.avi_control_state_code
WHERE state_type = 'E'
AND state_active_ind = 'A';
SELECT state_id
INTO state_closed
FROM vppstation.avi_control_state_code
WHERE state_type = 'D'
AND state_active_ind = 'A';
SELECT state_id
INTO state_all_report
FROM vppstation.avi_control_state_code
WHERE state_type = 'S'
AND state_active_ind = 'A';
current_station_id := -1;
current_avi_id := -1;
current_state_id := state_closed;
current_state_eff_date := in_time_from;
station_open_total := 0.0;
station_closed_total := 0.0;
station_all_report_total := 0.0;
-- for starters - ensure that there is report data for all requested stations...
INSERT INTO vpproadside.vpp_station_summary
vpp_report_seq_number,
station_id,
station_name,
ln_number,
lane_name,
station_open,
station_close,
station_all_report,
station_total
SELECT in_report_id,
vrs.station_id,
si.station_name,
l.ln_number,
l.lane_name,
0.0,
0.0,
0.0,
0.0
FROM vpproadside.vpp_report_stations vrs
LEFT OUTER JOIN vpproadside.stations_installed si
ON si.station_id = vrs.station_id
LEFT OUTER JOIN vppstation.lane_name l
ON l.station_id = vrs.station_id
WHERE vrs.vpp_report_seq_number = in_report_id;
-- loop over state history and update information for all stations found
OPEN station_loop;
LOOP
FETCH station_loop
INTO
next_station_id,
next_avi_id,
next_state_id,
next_state_eff_date;
IF station_loop%NOTFOUND THEN
next_station_id := -1;
next_avi_id := -1;
END IF;
-- if station/avi has changed take the end of the report period
IF (next_station_id <> current_station_id)
OR (next_avi_id <> current_avi_id)
THEN
period_length := in_time_to - current_state_eff_date;
ELSE
-- otherwise the start of the next period marks the end of the current period
period_length := next_state_eff_date - current_state_eff_date;
END IF;
-- if we have a real station id then do some work...
IF (current_station_id <> -1) THEN
-- determine which category the period fits to and apply calculation
IF current_state_id = state_open THEN
station_open_total := station_open_total + period_length - 1;
ELSIF current_state_id = state_closed THEN
station_closed_total := station_closed_total + period_length - 1;
ELSIF current_state_id = state_all_report THEN
station_all_report_total := station_all_report_total + period_length - 1;
ELSE
RAISE_APPLICATION_ERROR(-20111, 'Error: found unknown state code on avi_state_history - ' || current_state_id );
END IF;
-- if the station/avi has changed then commit changes to db
IF (next_station_id <> current_station_id)
OR (next_avi_id <> current_avi_id)
THEN
UPDATE vpproadside.vpp_station_summary
SET
station_open = station_open_total,
station_close = station_closed_total,
station_all_report = station_all_report_total
WHERE vpp_report_seq_number = in_report_id
AND station_id = current_station_id
AND ln_number = current_avi_id;
-- reset counts
station_open_total := 0.0;
station_closed_total := 0.0;
station_all_report_total := 0.0;
END IF;
END IF;
-- if we got past the last record then stop processing
EXIT WHEN station_loop%NOTFOUND;
-- if the station/avi is changing, get the state that was 'current' at in_time_from
IF (next_station_id <> current_station_id)
OR (next_avi_id <> current_avi_id)
THEN
current_state_eff_date := in_time_from;
OPEN entry_state (
next_station_id,
next_avi_id,
in_time_from
FETCH entry_state
INTO current_state_id;
IF entry_state%NOTFOUND THEN
current_state_id := state_closed;
END IF;
CLOSE entry_state;
period_length := next_state_eff_date - current_state_eff_date;
IF current_state_id = state_open THEN
station_open_total := station_open_total + period_length;
ELSIF current_state_id = state_closed THEN
station_closed_total := station_closed_total + period_length;
ELSIF current_state_id = state_all_report THEN
station_all_report_total := station_all_report_total + period_length;
ELSE
RAISE_APPLICATION_ERROR(-20111, 'Error: found unknown state code on avi_state_history - ' || current_state_id );
END IF;
END IF;
current_state_id := next_state_id;
current_state_eff_date := next_state_eff_date;
current_station_id := next_station_id;
current_avi_id := next_avi_id;
END LOOP;
CLOSE station_loop;
-- update the totals for the percentage calculation
UPDATE vpproadside.vpp_station_summary
SET
station_total = station_open + station_close+ station_all_report
WHERE vpp_report_seq_number = in_report_id;
-- 'fix' the totals that are still zero to avoid divide by zero errors...
-- note: all the percentages will still come out as zero since the total
-- was zero
UPDATE vpproadside.vpp_station_summary
SET
station_total = 1.0
WHERE vpp_report_seq_number = in_report_id
AND station_total = 0.0;
OPEN result FOR
SELECT station_name "Site Name",
lane_name "Lane Name",
TO_CHAR((station_open / station_total) * 100.0, 'FM990.0999') || '%' "Open %",
TO_CHAR((station_close / station_total) * 100.0, 'FM990.0999') || '%' "Closed %",
TO_CHAR((station_all_report / station_total) * 100.0, 'FM990.0999') || '%' "All Report %"
FROM vpproadside.vpp_station_summary
WHERE vpp_report_seq_number = in_report_id
ORDER BY UPPER(station_name),
UPPER(lane_name);
DELETE FROM vpproadside.vpp_station_summary
WHERE vpp_report_seq_number = in_report_id;
END;Edited by: Indhu Ram on Mar 10, 2010 9:51 AM
Edited by: Indhu Ram on Mar 10, 2010 9:56 AM
Edited by: Indhu Ram on Mar 10, 2010 10:58 AM
Edited by: Indhu Ram on Mar 10, 2010 11:12 AMExactly dont know what you are asking for but I can suggest you some tips here
- If you want to check the condition in SQL query then you can use CASE statement into select clause i.e.
SELECT CASE when table1.a=table2.b then table1.c else table2.c END, ... more case..., table columns...
FROM table1, table2
WHERE
<some conditions>
- If you want to achive same functionality (SELECT only, not UPDATE/INSERT/DELETE) then you can convert the part of same procedure into function and can use the same function into your query by passing the parameters.
something like this
SELECT function_name(parameter1, parameter2....) from dual
Hope this will help
Maybe you are looking for
-
Program name Report title 1. CACS00_PMNT_BLOCK_RESET Unlock Payment 2.
-
How to convert Labview document into PDF format
Hi! can any one tell me, can we convert the Labview document (Labview saved files)into PDF format. I wanted to convert it using a VI. If any one suggest me or send me the example vi i will be very thankful. Regards Ramesh.C
-
Hi I must to do alter table and add partition for column NM_CICLO_OPERACIONAL, with reanges When NM_CICLO_OPERACIONAL <= 200715 I put in partition, and others in other partition How can I do It ? CD_ESTRUTURA_COMERCIAL NUMBER(6)
-
Hello all. I'm really desperate. I hope you can help me: 1st) This is my project information: on FCPX 10.1.1 21 minutes. 1080p. 1.64GB file size if "sharing" at 1080p. First, it takes AGES to share such size, so I try to export at 480p (246MB). It al
-
Server 4.1 update went wrong
Hello, I run the server on a mac mini mid 2011 under 10.10.3. I updated yesterday the server application to the latest version and a error message showed up : [img]http://i.imgur.com/TQeAUTk.png[/img] Everything seems to work but the webdav connectio