Plsql query please help out
Hi ,
I have table with columns
item,product,class1,class2,item_path,category
How can I query the table to find out
same item_path with differnt categories.I want to update those rows.
Thanks.
If you're just trying to identify the paths with more than one category then something like...
select item_path, count(category) cnt
from mytable
group by item_path
having count(category) > 1may do it.
Similar Messages
-
How to improve the performance of the attached query, Please help
Hi,
How to improve performance of the below query, Please help. also attached explain plan -
SELECT Camp.Id,
rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount,
(SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
rCam.AccountKey as AccountKey
FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
WHERE Camp.AccountKey = rCam.AccountKey
AND Camp.AvCampaignKey = rCam.AvCampaignKey
AND Camp.AccountKey = CamBilling.AccountKey
AND Camp.CampaignKey = CamBilling.CampaignKey
AND rCam.AccountKey = xSite.AccountKey
AND rCam.AvSiteKey = xSite.AvSiteKey
AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
to_date('01-01-2011', 'DD-MM-YYYY')
GROUP By rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount
Explain Plan :-
Description Object_owner Object_name Cost Cardinality Bytes
SELECT STATEMENT, GOAL = ALL_ROWS 14 1 13
SORT AGGREGATE 1 13
VIEW GEMINI_REPORTING 14 1 13
HASH GROUP BY 14 1 103
NESTED LOOPS 13 1 103
HASH JOIN 12 1 85
TABLE ACCESS BY INDEX ROWID GEMINI_REPORTING RCAMSIT 2 4 100
NESTED LOOPS 9 5 325
HASH JOIN 7 1 40
SORT UNIQUE 2 1 18
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY SITE 2 1 18
INDEX RANGE SCAN GEMINI_PRIMARY SITE_I0 1 1
TABLE ACCESS FULL GEMINI_PRIMARY SITE 3 27 594
INDEX RANGE SCAN GEMINI_REPORTING RCAMSIT_I 1 1 5
TABLE ACCESS FULL GEMINI_PRIMARY CAMPAIGN 3 127 2540
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY CAMBILLING 1 1 18
INDEX UNIQUE SCAN GEMINI_PRIMARY CAMBILLING_U1 0 1Hello,
This has really nothing to do with the Oracle Forms product.
Please, send the SQL or/and PL/SQL questions in the corresponding forums.
Francois -
Every apps item on my iPad is having a different ID and the IDs are not known to me, invariably I don't know the passwords for the different IDs. I changed my ID with a view to maintain a common ID for all Apps items but the IDs for the individual App items severally remained unchanged. I guess the IDs belong to the person that downloaded the Apps items of which he is out of reach. Please help out.
All content from iTunes is tied to the account that originally bought/downloaded them, so only that account will able to download updates to them. You could delete those apps and buy and download your own copies of them
-
My IPad applications aren't working, they shout down immediately when I click them! Please help out!
I don't fully understand what the System Reset does but I've found that it cures many ills. It's easy, quick and harmless:
Hold down the on/off switch and the Home button simultaneously until you see the Apple logo. Ignore the "Slide to power off" text if it appears.
A System Reset does not remove any apps, music, movies, etc. nor does it cause any settings to revert back to default.
Also, you might wish to download the iPad-2 User Guide. Pay special attention to page 162. Note that this Guide also applies to the iPad-1 with IOS 4.3 except for those functions that are not supported by the hardware.
http://support.apple.com/manuals/#ipad
Finally, the User Guide can be downloaded at no charge via iBooks and a less comprehensive version of the Guide is included as a Safari bookmark. -
Pivot table query - PLEASE HELP
I have one requirement whichis similar like this.
I have following tables.
POSITIONS (one account holds multiple securities)
account_id security_id total
1 101 300
1 102 500
2 102 300
2 103 600
3 104 400
4 104 800
SECURITIES
security_id security_name country region
101 ABC USA NA
102 EFG USA NA
103 PQR GBR EUR
104 XYZ CANADA NA
I will get all the account numbers from front end application, for which I have to display output like this. For example I am getting accounts, 1,2,3 and 4 and have to display like columns at the end. I have to groupy by region and country.
REGION COUNTRY SECURITY_ID SECURITY_NAME 1 2 3 4
NA USA 101 ABC 300
102 EFG 500 300
COUNTRY TOTAL 800 300
CANADA 104 XYZ 400 800
REGION TOTAL 800 300 400 800
EUR GBR 103 PQR 600
COUNTRY TOTAL 600
REGION TOTAL 800 900 400 800
I am working on Oracle 9i Release 2 and front end is .net. Can anyone please help me out with a solution using a query or a stored proc. For Stored procedure, I should send refcurser as OUT parameter or any possible solution.
Thanks in advance.You could do the following:
In SQL
You can use the decode function and SUM over it.
Get the totals by region and country
select region,country, s.sec_id, sec_name,
sum(decode(acct_id,1,total,0)) a1,
sum(decode(acct_id,2,total,0)) a2,
sum(decode(acct_id,3,total,0)) a3,
sum(decode(acct_id,4,total,0)) a4
from positions p, securities s
where p.SEC_ID = s.SEC_ID
group by region,country, s.sec_id, sec_name
You can run similar sql to get totals by country or region separately ... just remove from select and group by clause the column name that you do not want to be displayed.
The limitation here is that you would need to write the decode statement for every account. Some programming may be needed here.
In PLSQL
create or replace procedure acct_sum (cr OUT sys_refcursor)
is
cursor c1 is
select distinct acct_id from positions order by 1 asc;
var1 varchar2(1000) := ' ';
var2 varchar2(1000);
begin
for i in c1 loop
var1 := var1 || ' sum(decode(acct_id, ' || i.acct_id || ', total,0) ),';
end loop;
var1 := substr(var1,1,length(var1)-1);
open cr for
'select region,country, s.sec_id, sec_name, ' || var1 ||
'from positions p, securities s
where p.SEC_ID = s.SEC_ID
group by region,country, s.sec_id, sec_name';
end acct_sum;
You may want to modify the code so pass in an array of accounts and loop through the content to get all the accounts.
Hope this helps
Shakti
http://www.impact-sol.com
Developers of Guggi Oracle - Tool for DBAs and Developers -
Hello Forum Members,
Can you please help me out:
SQL> select * from quarter_test4;
QUARTER CONFIG REP_DATE
Q1-2007 10 12-JAN-07
Q2-2007 10 21-APR-07
Q3-2007 870 14-AUG-07
Q4-2007 50 15-NOV-07
Q1-2008 60 02-JAN-09
Q4-2006 160 02-DEC-06
I want the following out put:
Please note that the future quarters should have current quarter sum(config).Please note that The current table
does not hold future quarters.I have to genarate query on which a report is based.
My Query:
SELECT quarter,
CASE
WHEN qtr > TRUNC(SYSDATE, 'q')
THEN LAST_VALUE(sum_config IGNORE NULLS) OVER(ORDER BY qtr)
ELSE sum_config
END sum_config
FROM (SELECT qtr, q.qtrstr quarter, SUM(qt.config) sum_config
FROM (SELECT 'Q' || TO_CHAR(qtr, 'q-yyyy') qtrstr, qtr
FROM (SELECT ADD_MONTHS(ADD_MONTHS(TRUNC(SYSDATE, 'q'), -13), 3 *(LEVEL - 1)) qtr
FROM DUAL
CONNECT BY LEVEL <= 9)
ORDER BY qtr) q,
quarter_test4 qt
WHERE qt.quarter(+) = q.qtrstr
GROUP BY qtr, q.qtrstr)
ORDER BY qtr;
Correct Output Generated:
QUARTER SUM_CONFIG
Q4-2006 160
Q1-2007 10
Q2-2007 10
Q3-2007 870
Q4-2007 50
Q1-2008 60
Q2-2008 60
Q3-2008 60
Q4-2008 60
====================================================================================================================================
New Requirement:Product column has been added.
SQL> select * from quarter_test3;
QUARTER CONFIG REP_DATE PRODUCT
Q1-2007 10 12-JAN-07 P1
Q2-2007 10 21-APR-07 P1
Q3-2007 870 14-AUG-07 P1
Q4-2007 50 15-NOV-07 P1
Q1-2008 60 02-JAN-09 P1
Q4-2006 160 02-DEC-06 P1
Q4-2006 997 02-DEC-06 P2
Q4-2007 60 14-NOV-07 P2
Q3-2007 970 14-NOV-07 P2
Q2-2007 20 21-APR-07 P2
Q1-2007 20 12-JAN-07 P2
QUARTER CONFIG REP_DATE PRODUCT
Q1-2008 70 12-JAN-08 P2
Expected Output:
Q4-2006 160 P1
Q1-2007 10 P1
Q2-2007 10 P1
Q3-2007 870 P1
Q4-2007 50 P1
Q1-2008 60 P1
Q2-2008 60 P1
Q3-2008 60 P1
Q4-2008 60 P1
Q4-2006 260 P2
Q1-2007 20 P2
Q2-2007 20 P2
Q3-2007 970 P2
Q4-2007 60 P2
Q1-2008 70 P2
Q2-2008 70 P2
Q3-2008 70 P2
Q4-2008 70 P2
My Query:
SELECT quarter,product,
CASE
WHEN qtr > TRUNC(SYSDATE, 'q')
THEN LAST_VALUE(sum_config IGNORE NULLS) OVER(ORDER BY qtr)
ELSE sum_config
END sum_config
FROM (SELECT qtr, q.qtrstr quarter,product, SUM(qt.config) sum_config
FROM (SELECT 'Q' || TO_CHAR(qtr, 'q-yyyy') qtrstr, qtr
FROM (SELECT ADD_MONTHS(ADD_MONTHS(TRUNC(SYSDATE, 'q'), -13), 3 *(LEVEL - 1)) qtr
FROM DUAL
CONNECT BY LEVEL <= 9)
ORDER BY qtr) q,
quarter_test3 qt
WHERE qt.quarter(+) = q.qtrstr
GROUP BY qtr,product, q.qtrstr)
ORDER BY substr(qtr,-4),substr(QTR,2,1)
Output:
QUARTER PRODUCT SUM_CONFIG
Q4-2006 P1 160
Q4-2006 P2 997
Q4-2007 P1 50
Q4-2007 P2 60
Q4-2008 70
Q2-2007 P1 10
Q2-2007 P2 20
Q2-2008 70
Q3-2007 P1 870
Q3-2007 P2 970
Q3-2008 70
QUARTER PRODUCT SUM_CONFIG
Q1-2007 P1 10
Q1-2007 P2 20
Q1-2008 P1 70
Q1-2008 P2 70
The query had not generated q2-2008,q3-2008,q4-2008 values [60]for P1...it had only generated q2-2008,q3-2008,q4-2008 values[70] for product P2.
Can you please advise me.You can make up the data using the model clause:
SQL> create table quarter_test3 (quarter, config, product)
2 as
3 select 'Q1-2007', 10, 'P1' from dual union all
4 select 'Q2-2007', 10, 'P1' from dual union all
5 select 'Q3-2007', 870, 'P1' from dual union all
6 select 'Q4-2007', 50, 'P1' from dual union all
7 select 'Q1-2008', 60, 'P1' from dual union all
8 select 'Q4-2006', 160, 'P1' from dual union all
9 select 'Q4-2006', 997, 'P2' from dual union all
10 select 'Q1-2007', 60, 'P2' from dual union all
11 select 'Q2-2007', 970, 'P2' from dual union all
12 select 'Q3-2007', 20, 'P2' from dual union all
13 select 'Q4-2007', 20, 'P2' from dual union all
14 select 'Q1-2008', 70, 'P2' from dual
15 /
Tabel is aangemaakt.
SQL> select 'Q' || to_char(mod(q,4) + 1) || '-' || to_char(trunc(q/4)) quarter
2 , config
3 , product
4 from quarter_test3
5 model
6 partition by (product)
7 dimension by (to_number(substr(quarter,4))*4 + to_number(substr(quarter,2,1)) - 1 q)
8 measures (config)
9 rules
10 ( config[for q from 2006*4 + 3 to 2008*4 + 3 increment 1]
11 = nvl(config[cv()],config[cv()-1])
12 )
13 order by product
14 , q
15 /
QUARTER CONFIG PR
Q4-2006 160 P1
Q1-2007 10 P1
Q2-2007 10 P1
Q3-2007 870 P1
Q4-2007 50 P1
Q1-2008 60 P1
Q2-2008 60 P1
Q3-2008 60 P1
Q4-2008 60 P1
Q4-2006 997 P2
Q1-2007 60 P2
Q2-2007 970 P2
Q3-2007 20 P2
Q4-2007 20 P2
Q1-2008 70 P2
Q2-2008 70 P2
Q3-2008 70 P2
Q4-2008 70 P2
18 rijen zijn geselecteerd.Regards,
Rob. -
Hi,
Currently we have a query (Created on Multicube - one is sales plan cube and another is Sales actuals).
When we run the query on a particular day (example: 7/10/2006), the report looks like as below:
Cal.Year/Month Sales plan Sales Actuals
Jan'06 310 305
Feb'06 280 277
Mar'06 310 309
Apr'06 300 300
MAy'06 310 305
June'06 300 305
July'06 310 90
The current report shows the whole month's Sales Plan (July'06 - 310) with Actual Sales for 9 days(for July'06 - 90). Whereas, We want to compare the sales Plan (first 9 days of the month) against the sales actuals for 9 days.
We do not have 0calday in both the cubes. Please help.
Thanks,David,
As rightly pointed out , you cannot get the plan value for 9 days if you do not have 0calday. However some things you can do...
1. Have a virtual KF which gets the number of days from the current calendar day ( system date ) to the first date of the month - this can be written with a simple exit since the first date is fixed.
2. calculate the plan value from that - pro rated plan value = plan value for month / number of days in month * number of days elapsed. If need be have the virtual KF return the ratio of number of days elapsed/number of days in the month
3. Now you can do the comparison assuming that the value of actuals will be till the current date and not beyond.
This is assuming that you can write a Virtual KF and the number of records is less enough to avoid any performance issues
Hope it helps..
Arun
Assign points if helpful
Message was edited by: Arun Varadarajan -
PROBLEM WITH HIERARCHICAL QUERY - PLEASE HELP
I have got three tables :
CREATE TABLE FIRM
(FID INTEGER NOT NULL PRIMARY KEY,
FNAME VARCHAR(40),
FTYPE VARCHAR(3),
MASTERID INTEGER );
CREATE TABLE FACULTY
(FAID INTEGER NOT NULL PRIMARY KEY,
FANAME VARCHAR(40),
FATYPE VARCHAR(3),
MASTERID INTEGER );
CREATE TABLE EMPLOYEE
(EID INTEGER NOT NULL PRIMARY KEY,
ENAME VARCHAR(20),
ESURNAME VARCHAR(20),
EJOB VARCHAR(3),
MASTERID INTEGER );
This is a hierarchical tree(or is ment to be, I,m complete rookie ) . Firm can be the root or can be slave to another firm. Faculty can be slave to firm, or to another faculty. Employee can be slave to faculty or to another employee(e.g. boss). This connections are specified by MASTERIDs.
I need to write a procedure, which parameter would be node ID. It is meant to create a VIEW from this node as if it was a root (view of a subtree).
I tried CONNECT BY clause but it works only on one table at a time and I have here three tables.
I completely don,t know how to write it. Please help.create view hierarchy as
select id, master_id, name from table1
union all
select id, master_id, name from table2
union all
select id, master_id, name from table3
Then do your connect by query against hierarchy.
It will not work in 8i (connect by on views not allowed), so you will need to materialize the view.
Kirill -
How to make recursive query.Please help
Dear Experts:
I want to retrieve all employees located in a department in addition to all other employees located in the child's nodes of this department too.
Problem Details:
I have "Employees" table and "Departments" Table
The structure of Dept Table is:
ID primary key
parent_dept foreign key(id)
deptname varchar2
deptType varchar2
The Employee table structure is
ID primary key
dept_id foreign key(Department.id)
empName varchar2Sample data for departments
ID : 1
parent_dept : null
deptname: General Manager office
deptType : 'GM'
ID :=2
parent_dept : 1
deptname: Information tech.
deptType : 'DPT'
ID :=3
parent_dept : 2
deptname: Software Development
deptType : 'SECTION'Sample Data for employees
ID : 101
dept_id :1
empName King
ID : 102
dept_id :2
empName ALAN
ID : 103
dept_id :2
empName SAM
ID : 104
dept_id :3
empName JANEI want to create a query that accepts a parameter "p_department_id" and returns All employees on the following conditions
1- In case the parameter value is null , then retrieve All Employees "king - alan- sam-jane"
2- In Case the parameter value is 1 , then retrieve all the employees under department id =1 in addition to all the employees located under the children departments.
in this case it will be "king - alan- sam-jane"
3- In case parameter value is 2 , then return all the employees under department id =2 in addition to all the employees located under the children departments.
In this case it will be " alan- sam-jane"
4- In case parameter value is 3 , then return all the employees under department id =3 in addition to all the employees located under the children departments.
in this case it will be only "JANE"
In brief , If I pass any value to the parameter :p_department_id , I want to retrieve all employees located in this department in addition to other employees located in the child's nodes of this department id
I use oracle database 11g release 2
Please help me
Thanks
Edited by: ta**** on Apr 3, 2013 5:56 PM
Edited by: ta**** on Apr 3, 2013 5:58 PMSQL> variable p_department_id number
SQL> exec :p_department_id := null
PL/SQL procedure successfully completed.
SQL> with employees as (
2 select 101 id,1 dept_id,'King' empName from dual union all
3 select 102,2,'ALAN' from dual union all
4 select 103,2,'SAM' from dual union all
5 select 104,3,'JANE' from dual
6 ),
7 departments as (
8 select 1 id,null parent_dept,'General Manager office' deptname,'GM' deptType from dual union all
9 select 2,1,'Information tech.','DPT' from dual union all
10 select 3,2,'Software Development','SECTION' from dual
11 )
12 select *
13 from employees
14 where dept_id in (
15 select id
16 from departments
17 start with (
18 (
19 :p_department_id is null
20 and
21 parent_dept is null
22 )
23 or
24 id = :p_department_id
25 )
26 connect by parent_dept = prior id
27 )
28 /
ID DEPT_ID EMPN
101 1 King
102 2 ALAN
103 2 SAM
104 3 JANE
SQL> exec :p_department_id := 1
PL/SQL procedure successfully completed.
SQL> /
ID DEPT_ID EMPN
101 1 King
102 2 ALAN
103 2 SAM
104 3 JANE
SQL> exec :p_department_id := 2
PL/SQL procedure successfully completed.
SQL> /
ID DEPT_ID EMPN
102 2 ALAN
103 2 SAM
104 3 JANE
SQL> exec :p_department_id := 3
PL/SQL procedure successfully completed.
SQL> /
ID DEPT_ID EMPN
104 3 JANE
SQL> SY. -
Table1
QTE_ID SEQ_NO
1435177 2
1435177 5
1435177 7
1435177 8
1435177 12
1435177 14
Table2
QTE_ID SEQ_NO CMMT_CURR_AMT
1435177 1 98500
1435177 2 98500
1435177 3 0
1435177 4 98500
1435177 5 98500
1435177 7 98500
1435177 8 98500
1435177 11 59300
1435177 12 59300
1435177 14 59300
The result should be
QTE_ID SEQ_NO CMMT_CURR_AMT
1435177 2 0 (where 0 = cmmt_curr_amt of seq 2 - cmmt_curr_amt of seq 1 from table 2)
1435177 5 0 (where 0 = cmmt_curr_amt of seq 5 - cmmt_curr_amt of seq 4 from table 2)
1435177 7 0 (where 0 = cmmt_curr_amt of seq 7 - cmmt_curr_amt of seq 5 from table 2)
1435177 8 0 (where 0 = cmmt_curr_amt of seq 8 - cmmt_curr_amt of seq 7 from table 2)
1435177 12 0 (where 0 = cmmt_curr_amt of seq 12 - cmmt_curr_amt of seq 11 from table 2)
1435177 14 0 (where 0 = cmmt_curr_amt of seq 14 - cmmt_curr_amt of seq 12 from table 2)
I have to get the difference of cmmt_curr_amt from the table2 from seq 14 to seq 12 for seq14 in table 1.
Please help me in writing the query.
Thanks in advance.
SrinivasWITH table1 AS
(SELECT 1435177 qte_id, 2 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no
FROM dual
table2 AS
SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
FROM dual
SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
FROM
(SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
FROM table1 t1, table2 t2
WHERE t2.qte_id = t1.qte_id (+)
AND t2.seq_no = t1.seq_no(+)
ORDER BY 1,2
WHERE t1_seq_no IS NOT NULL
ORDER BY 1,2
QTE_ID T2_SEQ_NO DIFF
1435177 2 0
1435177 5 0
1435177 7 0
1435177 8 0
1435177 12 0
1435177 14 0 -
How to rewrite this query without sub query please help me
Hello All Good Evening,
Could you please help me with this query, how can i write this query without sub query, or how can write this query another ways
please help me
select planno, status1, count(*) Counts from
select a.ValetNO PlanNo ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end Status1 ---, COUNT (*)
from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
--group by a.ValetNO
a group by planno, status1
order by 2
Thank you in Advance
MilanWhats your objective here? Sorry, am not able to understand the reason for this change.
Try the below:(Not tested)
;With cte
As
select a.ValetNO PlanNo ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end Status1 ---, COUNT (*)
from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
select planno, status1, count(*) Counts from cte
a group by planno, status1
order by 2
Even below:
select a.ValetNO PlanNo ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end Status1 , COUNT (1)
from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
Group by a.ValetNO ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end -
Problem while designing query please help
Hi all,
I have to query to find No of open cases, No of closed cases,
Average of open cases, Average age of closed cases,
Maximum of closed cases for a particulat Current assigne(char).
my desired output is as follows.
CurAssigne Noofopencases Noofclosed cases Avgage(opencases) Max(open)
CurAssigne1 10 20 8 9
CurAssigne1 18 22 9 10
My cube is consists of.
4 Dimensions & 4 key figures
4Dimensions are listed below.
Business Partner{currentassigne, previousassigne,acmanager}
createdon{createdonmonth,createdonday,createdtime}
closedon{closedmonth,closedday,closedtime}
Status{Latest case status-(2 status are available for each case - open,close)}
above the objects between {} are chars.
4 keys are listed below.
no of cases.
age
first response time
research time.
Please help me to design this query friends..
It's very urgent friends please help me.Hi,
Please share your system configuration on which you are trying to install Ps CS6.
Regards,
Ashutosh
Ps Installer QE -
Passing parameter to a SQL query - Please help
Hi All,
I am new to JDBC. I have been trying to pass an external variable to an SQL Query.
The query is
String username1="le";
PreparedStatement pstmt = null;
pstmt = c.prepareStatement("select * from users where USER_NAME like '%?%'");
pstmt.setString(1, username1);
pstmt.executeQuery();
ResultSet rs = pstmt.getResultSet();
I am trying to retrieve values from the users table where the USER_NAME column value that is a String contains the supplied value username1.
I am using the question mark (?) character to pass the value from the variable username1. I am also using the '%' substitution character which matches for any number of characters. So, the above query should retrieve rows where the USER_NAME is something like "charles","leander","Elena" etc.( that contains "le")
I am getting the error:
SQLException: java.sql.SQLException: ORA-01006: bind variable does not exist
I changed the query to
PreparedStatement pstmt = null;
pstmt = c.prepareStatement("select * from users where USER_NAME like '% " + username1 + "%'");
//pstmt.setString(1, username1);
pstmt.executeQuery();
This time , it is not giving the error and retrieving properly.
But I want to use the original query and use the "pstmt.setString(1, username1); " . Is there any way of achieving this?
Please help.
Cheers,
charles_amhi,
try this...
String username1="%le%";
pstmt = c.prepareStatement("select * from users where USER_NAME like ?")
pstmt.setString(1,username1);
cheers,
rpk -
Please help out with a solution
My blackberry curve 9360 gets heated up, the track pad is not functioning properly, gets switched off automatically and gets hanged, Battery drains in less than 5 hours. Once you run any app, it becomes over heated. It started giving me software problems also. After getting it checked at the service centers in Gurgaon they refused to replace the phone and it is not even 1year of its purchase. Please help me out with a solution.
will be thankful to youHello
That is most likely a OS issue, especially the first version of OS 7. I faced the same problem with my 9360.
See this link : http://supportforums.blackberry.com/t5/BlackBerry-Curve/9360-the-official-OS-releases/td-p/1339817
The above will point you in the right direction as to where to download your OS , as all carriers are listed with a link found at the bottom of the page for instructions on how to reload OS.
Good luck. -
Hi experts,
what i want to do is write a single query which will show whether a employee
exits in the company or not.I have two tables emp and dept.There are as follows.
SQL> select * from emp;
NAME DEPTNO EMPNO
xxx 10 33036
YYY 12 2345
ZZZ 13 678
KKK 14 5678
RRR 15 7865
SQL> select * from dept;
DEPTNO LOCATION
10 AAA
11 BBB
12 CCC
13 DDD
what i want is it will select records from the emp table and find whether corrosponding
deptno really exists in the dept table.If the value is found in deptno column the dept table then it will set the value
Y other wise it will be N and all i have to do with the help of a single query.
expected result
name empno exists
xxx 33036 Y
YYY 2345 Y
ZZZ 678 Y
KKK 5678 N
RRR 7865 N
Please help.
Regards
RajatSELECT EMPNO, NAME , EMPNO , NVL( ( SELECT 'Y' FROM DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO),'N') EXIST
FROM EMP
ORDER BY 1
Demo
SQL> WITH EMP AS(
2 SELECT 'XXX' NAME , 10 DEPTNO ,33036 EMPNO FROM DUAL UNION
3 SELECT 'YYY', 12, 2345 FROM DUAL UNION
4 SELECT 'ZZZ', 13 ,678 FROM DUAL UNION
5 SELECT 'KKK', 14 ,5678 FROM DUAL UNION
6 SELECT 'RRR', 15 ,7865 FROM DUAL ),
7 DEPT AS(
8 SELECT 10 DEPTNO,'AAA' DNAME FROM DUAL UNION
9 SELECT 11 ,'BBB' FROM DUAL UNION
10 SELECT 12 ,'CCC' FROM DUAL UNION
11 SELECT 13 ,'DDD'FROM DUAL )
12 SELECT EMPNO, NAME , EMPNO , NVL( ( SELECT 'Y' FROM DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO),'N')
EXIST
13 FROM EMP
14 ORDER BY 1
15 /
EMPNO NAM EMPNO E
678 ZZZ 678 Y
2345 YYY 2345 Y
5678 KKK 5678 N
7865 RRR 7865 N
33036 XXX 33036 Y
SQL> Edited by: Salim Chelabi on Dec 7, 2008 4:15 AM
Maybe you are looking for
-
On MSN I can not view Cam or peoples videos they send
anyone know the answer?
-
Acrobat 7 Pro - form won't submit via email, and data won't submit either
Hi. I am trying to create a form for end users at my website to be able to open the form in Reader, enter their data in the form, and click on the "Submit" button to email it back to me (or any other way it can come back would be okay... as long as I
-
Portal configuration steps don't show up????
First it pop up a configuration dialog. Then it disappeared. I can't get the steps to fill. No password.no database. But i can log into portal. i can build calendar, but not forms, reports within portal. any help???
-
Can't use itunes anymore... please help me!
Every time I try launchin iTunes, I get an error message telling me I have quicktime version "7.0d0" installed and that I need version 7.0.3. I reinstalled quicktime, now it's version 7.1, reinstalled itunes twice, nothing works.. does anybody know w
-
I upgraded Photoshop CC the other night, and now nothing in the Filter Gallery works. Other filters like Gaussian Blur work fine. I'm running Mavericks on a Mac Pro laptop. All filters were working on the same file before the upgrade.