Possible in a single query ...?
We have one question master table as...
questionnumber number(3),
answer char(1)
And another table candidate_choice table as...
candidatesrno number(6),
questionnumber number(3),
answer char(1),
marks number(5,2)
Candidate entries are stored in candidate_choice table. Now we have to prepare marks sheet. For this we need to compare each candidate's answer with question master table and it it matches, we have to give 1 mark. And if it does not match we have to give -1 marks. And total marks is to be stored in marks column of candidate_choice table.
How can we write single SQL query to do this ?
(we are using Oracle 9i R. 2)
Thanks,
Kiran Shah.
Nice point Kamal. I forget to give one Candidate master table details.
So actually is goes like this...(with little modification in Candidate_choice table)
Table : Candidate master
create table jacademy(
candidatesrno number(6),
name varchar2(100),
Marks number(5,2))
Values
insert into jacademy values(1, 'Kiran Shah', NULL)
insert into jacademy values(2, 'Ramesh Mande', NULL)
insert into jacademy values(3, 'Saseendran', NULL)
question master table as...
create table qmaster(
questionnumber number(3),
answer char(1))
values
insert into qmaster values(1, 'T')
insert into qmaster values(2, 'F')
insert into qmaster values(3, 'T')
And another table candidate_choice table as...
create table candidate_choice(
candidatesrno number(6),
questionnumber number(3),
answer char(1))
values
insert into candidate_choice values(1,1,'T')
insert into candidate_choice values(1,2,'T')
insert into candidate_choice values(1,3,'F')
Now we have to prepare marks sheet. For this we need to compare each candidate's answer with question master table and it it matches, we have to give 1 mark. And if it does not match we have to give -1 marks. And total marks is to be stored in marks column of candidate master table.
Thanks...
Similar Messages
-
Is this possible in a single query?????
While I don't think this is possible in a single query, I definately don't have the background the experts here have.
I have a request to identify all shipments in a period/range of periods that have a payment transaction. For those shipments, the user wants a list of all payment transactions and the initial accrual entry listed by period for potentially a large range of periods. The accrual and payment entries are identifed by the same characteristic and a 0Amount key figure contains the values. A couple methods I have tried I have listed in previous threads with either errors or the query blowing up with what appears to be a cartesian product issue.
Anyone done something like this who can provide pointers.
BillHi Bill,
Why dont u use RRI-report to report interface for this Requierment ??
There are lots of threads on RRI ,just follow them and u can satisfy this requirement.
1)Query A for Shipments
2)Query B for Payment Transactions.
Call report B from Report A
1)GOTO RSBBS
2)Create New
3)Sender Query Give the First Query Report A
4)Below sender Query there is Receiver Query give the RRI query report B (The query which u want to call).Report type should be BEX ,and Target system--Assign the System(Local) and in the report give the Report B.
5)In the Report A check whether in the GOTO -u get the Receiver Query ,i.e Report B.
Hope this help !!!!!!!!!
Rgds
SVU123 -
Is a single Query possible for this?
Hi everyone,
I have a requirement to get a list of 10 free (non-assigned) ids from a table. The ids range from say 1-32000. The table contains only the assigned ids. So the idea is - if say we have 15 records already in this table like 2,7,23,4,65,22,665... etc (random, non-repeated, unsorted values), then I need to get the first 10 numbers in the range 1-32000 which are not there in the table e.g. 1,3,4,5,6,8,...etc. One idea is to have a table2 with a single column having values 1-32000 i.e. 32000 rows. Then we can give the query like -
select col1 from table2 where rownum<=10 and col1 not in (select id from table1);
Is there a better way to get this output without having a separate table with 32000 rows? Or, is it possible to form a faster query even with the proposed solution?
Thanks,
Regards
Sanchayan
null<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by [email protected]:
Hi everyone,
I have a requirement to get a list of 10 free (non-assigned) ids from a table. The ids range from say 1-32000. The table contains only the assigned ids. So the idea is - if say we have 15 records already in this table like 2,7,23,4,65,22,665... etc (random, non-repeated, unsorted values), then I need to get the first 10 numbers in the range 1-32000 which are not there in the table e.g. 1,3,4,5,6,8,...etc. One idea is to have a table2 with a single column having values 1-32000 i.e. 32000 rows. Then we can give the query like -
select col1 from table2 where rownum<=10 and col1 not in (select id from table1);
Is there a better way to get this output without having a separate table with 32000 rows? Or, is it possible to form a faster query even with the proposed solution?
Thanks,
Regards
Sanchayan<HR></BLOCKQUOTE>
Sanchayan,
Your problem can be solved by a single query.
Try the following query:
(THIS WILL GIVE AN IDEA")
select * from (
select rownum from (select numero from srm_test)
minus
select numero from srm_test)
where rownum < 10
order by 1
YOU WILL GET:
ROWNUM
1
3
6
8
10
11
12
7 rows selected.
The contents of srm_test are:
2, 7, 23, 4, 65, 22, 665, 90, 87, 200, 9, 5
null -
Is it possible to run 2 different reports SEPARATELY from a single query?
Dear All,
The title to my previous thread seems to be inaccurate and misleading.
To encourage people to read it, I am giving it a more appropriate Title.
Please do not reply on this thread, but refer to the original one.
Thanks
Leon Lai
Here's the link:
Is it possible to combine 2 different reports in a single Query?Dear All,
The title to my previous thread seems to be inaccurate and misleading.
To encourage people to read it, I am giving it a more appropriate Title.
Please do not reply on this thread, but refer to the original one.
Thanks
Leon Lai
Here's the link:
Is it possible to combine 2 different reports in a single Query? -
Is it possible to combine 2 different reports in a single Query?
Dear All,
What am I working at?
I produced a Query for Debtors Aged Analysis which mimics the Official SAP B1 8.8 Aging Report.
It ages the outstanding invoices by Posting Date ( RefDate in JDT1)
I also made another Report which ages outstanding amounts by Document Date simply by replacing all RefDate by TaxDate
They give different answers if Posting Date is different from Document Date, e.g a manual invoice dated 5 Jun 2011 is posted on 2 Jul 2011.
What I want to do?
My idea is to produce a SINGLE QUERY which will generate either Aging depending on settings:
(a) A Debtors Aging by Posting Date
(b) A Debtors Aging by Document Date
I declare 2 variables:
(a) @refdt is [%1] and represents Posting Date (JDT1 RefDate)
(b) @taxdt is [%2] and represents Document Date (JDT1 TaxDate)
When the Query is run, the foll dialog appears:
Query - Selection Criteria
Posting Date Equal .......
Document Date Equal .......
OK Cancel
We are expected to fill in only 1 date and leave the other blank, and Query will generate the required report .
What is my problem?
Query runs smoothly, but amounts in the Balance column does not get analyzed in the Age brackets: Current / 1 Mth Ago / etc
I think I know where's the problem
I am assuming (wrongly) that if we don't fill one date field, the query returns NULL for that variable. In fact, it appears to return GetDate().
Help
Can anybody help me put the correct commands so that all my balances are correctly analysed in the respective age buckets?
Thanks
Leon Lai
Here's a simplified SQL:
Tables :
JDT1 T0 = Journal Entry - Rows
OCRD T1 = Business Partner
OCPR T2 = Contact Person
OJDT T3 = Journal Entry - Header
OINV T4 = A/R Invoices - Header
ORIN T5 - A/R Credit Memo - Header
declare @refdt date
declare @taxdt date
set @refdt
/*Select 1 from jdt1 t where t.RefDate*/ = [%1]
set @taxdt
/*Select 1 from jdt1 w where w.TaxDate*/ = [%2]
SELECT
'company1' AS 'Company',
T1.CardCode AS 'BP Code',
T2.Notes2 AS 'BP Name',
T0.RefDate AS 'Pstg Dt',
T0.TaxDate AS 'Doc Dt',
CASE
WHEN T0.TransType = 13 THEN 'IN'
WHEN T0.TransType = 14 THEN 'CN'
WHEN T0.TransType = 30 THEN 'JE'
WHEN T0.TransType = 24 THEN 'RC'
WHEN T0.TransType = 46 THEN 'PS'
ELSE 'Error ! ! !'
END AS 'Doc Type',
T0.Ref1 'Doc. Number',
ISNULL(T0.FCCurrency, ' - ') AS 'Ccy',
(T0.FCDebit - T0.FCCredit) AS 'Orig. F.Ccy',
(T0.BalFcDeb - T0.BalFcCred) AS 'Bal. F. Ccy',
(T0.Debit - T0.Credit) AS 'Orig. Rs',
(T0.BalDueDeb - T0.BalDueCred) AS 'Bal. Rs',
/* ######################## PROBLEM is here ################## */
CASE
WHEN (@refdt is not null) and (@taxdt is null)
THEN ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred
WHERE DateDiff(mm, T0.RefDate, @refdt) = 0 ) ,0)
WHEN (@refdt is null) and (@taxdt is not null)
THEN ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred
WHERE DateDiff(mm, T0.TaxDate, @taxdt) = 0 ) ,0)
END AS 'Current Mth',
CASE
WHEN (@refdt is not null) and (@taxdt is null)
THEN ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred
WHERE DateDiff(mm, T0.RefDate, @refdt) = 1 ) ,0)
WHEN (@refdt is null) and (@taxdt is not null)
THEN ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred
WHERE DateDiff(mm, T0.TaxDate, @taxdt) = 1 ) ,0)
END AS '1 Mth Ago'
/* Similarly for other age buckets */
FROM company1.dbo.JDT1 T0
INNER JOIN company1.dbo.OCRD T1 ON T0.ShortName = T1.CardCode
LEFT OUTER JOIN company1.dbo.OCPR T2 ON T1.CardCode = T2.Cardcode
LEFT OUTER JOIN company1.dbo.OJDT T3 ON T0.TransID = T3.TransID
LEFT OUTER JOIN company1.dbo.OINV T4 ON T3.TransID = T4.TransID
LEFT OUTER JOIN company1.dbo.ORIN T5 ON T3.TransID = T5.TransID
WHERE
T1.CardType = 'C' and Balance != 0
and (T0.BalDueDeb - T0.BalDueCred) != 0HI
I generate the next aged analysis
CREATE PROCEDURE [dbo].[Aged_Analysis] (@end datetime,@Client VarChar (20)) AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @SAPUNION Table (SN VarChar(50), TransId Int, ReconSum Decimal(19,2), DebHab VarChar(1),
Linea Int)
insert into @SAPUNION
SELECT X0.ShortName 'SN', X0.TransId 'TransId', SUM(X0.ReconSum)'ReconSum', X0.IsCredit 'DebHab', X0.TransRowId 'Linea'
FROM ITR1 X0
INNER JOIN OITR X1 ON X1.ReconNum = X0.ReconNum
WHERE X1.ReconDate <= @end AND X1.CancelAbs = ''
GROUP BY X0.ShortName, X0.TransId, X0.IsCredit, X0.TransRowId
SELECT T0.CardCode, T0.CardName,T0.Address,T0.CreditLine,
T1.TransId , T4.BaseRef , T1.Ref2 , T1.RefDate, T1.DueDate,
CASE
WHEN T3.DebHab = 'D' THEN T1.Debit-T1.Credit-T3.ReconSum
WHEN T3.DebHab = 'C' THEN T1.Debit-T1.Credit+T3.ReconSum
ELSE (T1.Debit-T1.Credit)
END 'Balance',
CASE
when DateDiff(Day,t1.RefDate,GetDate()) <= 30 and T3.DebHab = 'D' then T1.Debit-T1.Credit-T3.ReconSum
when DateDiff(Day,t1.RefDate,GetDate()) <= 30 and T3.DebHab = 'C' then T1.Debit-T1.Credit+T3.ReconSum
when DateDiff(Day,t1.RefDate,GetDate()) <= 30 then (T1.Debit-T1.Credit) end '0-30 dias',
CASE
when DateDiff(Day,t1.refdate,GetDate()) between 31 and 45 and T3.DebHab = 'D' then T1.Debit-T1.Credit-T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) between 31 and 45 and T3.DebHab = 'C' then T1.Debit-T1.Credit+T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) between 31 and 45 then (T1.Debit-T1.Credit) end '31-45 dias',
CASE
when DateDiff(Day,t1.refdate,GetDate()) between 46 and 60 and T3.DebHab = 'D' then T1.Debit-T1.Credit-T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) between 46 and 60 and T3.DebHab = 'C' then T1.Debit-T1.Credit+T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) between 46 and 60 then (T1.Debit-T1.Credit) end '46-60 dias',
CASE
when DateDiff(Day,t1.refdate,GetDate()) between 61 and 75 and T3.DebHab = 'D' then T1.Debit-T1.Credit-T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) between 61 and 75 and T3.DebHab = 'C' then T1.Debit-T1.Credit+T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) between 61 and 75 then (T1.Debit-T1.Credit) end '61-75 dias',
CASE
when DateDiff(Day,t1.refdate,GetDate()) BETWEEN 76 AND 89 and T3.DebHab = 'D' then T1.Debit-T1.Credit-T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) BETWEEN 76 AND 89 and T3.DebHab = 'C' then T1.Debit-T1.Credit+T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) BETWEEN 76 AND 89 then (T1.Debit-T1.Credit) end '76-89 dias',
CASE
when DateDiff(Day,t1.refdate,GetDate()) >90 and T3.DebHab = 'D' then T1.Debit-T1.Credit-T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) >90 and T3.DebHab = 'C' then T1.Debit-T1.Credit+T3.ReconSum
when DateDiff(Day,t1.refdate,GetDate()) >90 then (T1.Debit-T1.Credit) end '90-Mas',
CASE T1.TransType
WHEN '13' THEN (SELECT Y.Comments FROM OINV Y WHERE Y.TransId = T1.TransId)
WHEN '14' THEN (SELECT Y.Comments FROM ORIN Y WHERE Y.TransId = T1.TransId)
WHEN '24' THEN (SELECT Y.Comments FROM ORCT Y WHERE Y.TransId = T1.TransId)
ELSE T1.LineMemo
END 'Comments'
FROM OCRD T0
INNER JOIN JDT1 T1 ON T1.ShortName = T0.CardCode
INNER JOIN OACT T2 ON T2.AcctCode = T1.Account
INNER JOIN OJDT T4 ON T4.TransId = T1.TransId
LEFT JOIN OINV T5 ON T5.TransId = T4.TransId and t5.ObjType = t4.TransType
LEFT JOIN @SAPUNION T3 ON T3.TransId = T1.TransId AND T3.SN = T1.ShortName AND T3.Linea = T1.Line_ID
WHERE T0.CardType = 'C' /*FOR CLIENTS*/ AND T1.RefDate <= @end AND T2.AcctCode = /*YOUR CLIENT ACCOUNT*/ AND
(CASE
WHEN T3.DebHab = 'D' THEN (T1.Debit-T1.Credit-T3.ReconSum)
WHEN T3.DebHab = 'C' THEN (T1.Debit-T1.Credit+T3.ReconSum)
ELSE (T1.Debit-T1.Credit)
END) != '0'
AND T0.CardCode= @Client
ORDER BY T0.CardCode,T1.TransId,t1.Ref2
END
AND Execute by SAP
DECLARE @VAR INT, @DATE DATETIME, @BP VARCHAR(8)
SET @VAR = (SELECT TOP 1 T.DocEntry FROM [dbo].[OINV] T WHERE T.DocDate <='[%0]' AND T.CardCode='[%1]')
SET @DATE = '[%0]'
SET @BP = '[%1]'
EXECUTE [dbo].[Aged_Analysis]
@end = @DATE,
@Client = @BP
Regards
Floyola
Edited by: Floyola on Jul 22, 2011 10:17 AM -
Multiple databases in a single query
I need to query multiple databases in a single query.
e.g.
Database d1 contains table t1 with column id
Database d2 contains table t2 with column id
I need a query like
SELECT * FROM t1, t2 WHERE t1.id = t2.id;
is this possible in jdbc? if yes can anyone help with some sample code?
thanks,
Ashish SarafIt is not possible using the JDBC API to query tables in two or more databases using a single query. The reason is that a JDBC Connection is made to a single data source.
However, some databases support the idea of federations or linked tables. What you do is inside the database manager link or federate a table that is present in another DBMS. Then, pose a single JDBC query to the one DBMS which will have its own table and links to the external tables.
Another approach is to use a special JDBC driver with a built-in integration engine that will perform a query across multiple databases. In effect, the system poses separate queries to the different databases and integrates and joins the data together for you automatically on the client-side. That is much easier than doing it yourself in code, but that is also possible for simple queries.
As part of my research program, we have released a shareware version of the UnityJDBC driver that can query multiple databases using a single SQL query. For more information, see:
http://www.unityjdbc.com
http://www.cs.uiowa.edu/~rlawrenc/research/projects.html
Sincerely,
Dr. Ramon Lawrence
Assistant Professor
Department of Computer Science
University of Iowa
[email protected] -
All selected 'n' consecutive rows in retrieved in a single query
hello,
I have table T with 50,000 rows
create table T
(student_id number,
class_id number,
quiz_id number,
marks number)
some sample rows like
INSERT INTO T VALUES (1,1, 1, 50);
INSERT INTO T VALUES (2,2, 2, 40);
INSERT INTO T VALUES (3,1, 3, 34);
INSERT INTO T VALUES (1,1, 4, 10);
INSERT INTO T VALUES (1,1, 5, 30);
INSERT INTO T VALUES (1,1, 6, 29);
INSERT INTO T VALUES (3,2, 7, 34);
INSERT INTO T VALUES (3,2, 8, 33);
INSERT INTO T VALUES (3,2, 9, 56);
INSERT INTO T VALUES (1,1, 7, 90);
INSERT INTO T VALUES (2,2, 8, 0,);
INSERT INTO T VALUES (1,1, 8, 80);
INSERT INTO T VALUES (2,2, 8, 65);
INSERT INTO T VALUES (1,1, 9, 34);
INSERT INTO T VALUES (2,2, 9, 11);each student belongs to one class_id. each student participates in many quizes. each quiz has its unique id. each student can appear once in a quiz_id
I am doing the below analysis and query:
1. with below query I am finding which student_id had most marks in any 3 successive quizes (see the 3-1 part below) in the query..
SELECT QUIZ_ID,
STUDENT_ID,
SUM (MARKS) OVER (PARTITION BY STUDENT_ID ORDER BY QUIZ_ID1
RANGE BETWEEN CURRENT ROW AND (3-1) FOLLOWING) consecMARKS , MARKS FROM
(SELECT QUIZ_ID,
STUDENT_ID,
MARKS,
ROW_NUMBER() OVER (PARTITION BY STUDENT_ID ORDER BY T.QUIZ_ID) QUIZ_ID1
FROM T
WHERE MARKS IS NOT NULL
ORDER BY 1
ORDER BY 3 DESC
SQL> /
QUIZ_ID STUDENT_ID CONSECMARKS
7 1 170
6 1 166
8 1 129
5 1 106
8 3 89
8 2 76
3 3 68
7 3 67
8 2 65
1 1 60
9 3 56
QUIZ_ID STUDENT_ID CONSECMARKS
9 1 49
2 2 40
4 1 40
9 2 11
15 rows selected.With above query, I can play around and find for any 'n' number of consecutive quizes, like marks in 2 consecutives quizes, 3, 4 and so on but for each 'n' value I've to run a seperate query mentioning (2-1) or (3-1) or (4-1) and so on..
since my table is big and there are about 400 quizes so what I want to find out is for each 'n' consecutive quiz (from 1 to 400) which student had most marks for each consecutie 'n' quiz. Like in 1 (consecutive) quiz which student had the highest marks and then 2 conseuctive quiz who had most marks and then in 3 consecutive quiz who had most marks and so on till 400 consecutive quiz who had most marks... rather than running query for each 'n' value seperately i want a single query that can give me a summary of most marks in each n consecutive quizes...
my sample output is:
Nth consecutive quiz student_id sum(marks)
1 1 90
2 1 170
3 1 246
4
100
200
300
400 ? ? Is this possible to get the above output from one single query? If there are two or more students with equal most marks for any 'n' conseutive quizes then both should come in the summary.
Hope I have been able to put up my question clearly.
regards
RamisSomething like:
SELECT N,
QUIZ_ID,
STUDENT_ID,
SUM(MARKS) OVER (PARTITION BY N,STUDENT_ID ORDER BY QUIZ_ID1 RANGE BETWEEN CURRENT ROW AND (N-1) FOLLOWING) consecMARKS,
MARKS
FROM (SELECT QUIZ_ID,
STUDENT_ID,
MARKS,
ROW_NUMBER() OVER (PARTITION BY STUDENT_ID ORDER BY T.QUIZ_ID) QUIZ_ID1
FROM T
WHERE MARKS IS NOT NULL
SELECT LEVEL N
FROM DUAL
CONNECT BY LEVEL <= (
SELECT COUNT(DISTINCT QUIZ_ID)
FROM T
ORDER BY N,
consecMARKS DESC
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
1 7 1 90 90
1 8 1 80 80
1 8 2 65 65
1 9 3 56 56
1 1 1 50 50
1 2 2 40 40
1 9 1 34 34
1 7 3 34 34
1 3 3 34 34
1 8 3 33 33
1 5 1 30 30
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
1 6 1 29 29
1 9 2 11 11
1 4 1 10 10
1 8 2 0 0
2 7 1 170 90
2 6 1 119 29
2 8 1 114 80
2 8 3 89 33
2 8 2 76 65
2 3 3 68 34
2 7 3 67 34
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
2 8 2 65 0
2 1 1 60 50
2 5 1 59 30
2 9 3 56 56
2 2 2 40 40
2 4 1 40 10
2 9 1 34 34
2 9 2 11 11
3 7 1 204 90
3 6 1 199 29
3 5 1 149 30
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
3 7 3 123 34
3 8 1 114 80
3 2 2 105 40
3 3 3 101 34
3 1 1 90 50
3 8 3 89 33
3 8 2 76 65
3 8 2 76 0
3 4 1 69 10
3 9 3 56 56
3 9 1 34 34
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
3 9 2 11 11
4 6 1 233 29
4 5 1 229 30
4 7 1 204 90
4 4 1 159 10
4 3 3 157 34
4 7 3 123 34
4 1 1 119 50
4 2 2 116 40
4 8 1 114 80
4 8 3 89 33
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
4 8 2 76 0
4 8 2 76 65
4 9 3 56 56
4 9 1 34 34
4 9 2 11 11
5 5 1 263 30
5 4 1 239 10
5 6 1 233 29
5 1 1 209 50
5 7 1 204 90
5 3 3 157 34
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
5 7 3 123 34
5 2 2 116 40
5 8 1 114 80
5 8 3 89 33
5 8 2 76 0
5 8 2 76 65
5 9 3 56 56
5 9 1 34 34
5 9 2 11 11
6 1 1 289 50
6 4 1 273 10
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
6 5 1 263 30
6 6 1 233 29
6 7 1 204 90
6 3 3 157 34
6 7 3 123 34
6 2 2 116 40
6 8 1 114 80
6 8 3 89 33
6 8 2 76 0
6 8 2 76 65
6 9 3 56 56
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
6 9 1 34 34
6 9 2 11 11
7 1 1 323 50
7 4 1 273 10
7 5 1 263 30
7 6 1 233 29
7 7 1 204 90
7 3 3 157 34
7 7 3 123 34
7 2 2 116 40
7 8 1 114 80
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
7 8 3 89 33
7 8 2 76 0
7 8 2 76 65
7 9 3 56 56
7 9 1 34 34
7 9 2 11 11
8 1 1 323 50
8 4 1 273 10
8 5 1 263 30
8 6 1 233 29
8 7 1 204 90
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
8 3 3 157 34
8 7 3 123 34
8 2 2 116 40
8 8 1 114 80
8 8 3 89 33
8 8 2 76 0
8 8 2 76 65
8 9 3 56 56
8 9 1 34 34
8 9 2 11 11
9 1 1 323 50
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
9 4 1 273 10
9 5 1 263 30
9 6 1 233 29
9 7 1 204 90
9 3 3 157 34
9 7 3 123 34
9 2 2 116 40
9 8 1 114 80
9 8 3 89 33
9 8 2 76 0
9 8 2 76 65
N QUIZ_ID STUDENT_ID CONSECMARKS MARKS
9 9 3 56 56
9 9 1 34 34
9 9 2 11 11
135 rows selected.
SQL> SY. -
How to calculate the area of a large number of polygons in a single query
Hi forum
Is it possible to calculate the area of a large number of polygons in a single query using a combination of SDO_AGGR_UNION and SDO_AREA? So far, I have tried doing something similar to this:
select sdo_geom.sdo_area((
select sdo_aggr_union ( sdoaggrtype(mg.geoloc, 0.005))
from mapv_gravsted_00182 mg
where mg.dblink = 521 or mg.dblink = 94 or mg.dblink = 38 <many many more....>),
0.0005) calc_area from dualThe table MAPV_GRAVSTED_00182 contains 2 fields - geoloc (SDO_GEOMETRY) and dblink (Id field) needed for querying specific polygons.
As far as I can see, I need to first somehow get a single SDO_GEOMETRY object and use this as input for the SDO_AREA function. But I'm not 100% sure, that I'm doing this the right way. This query is very inefficient, and sometimes fails with strange errors like "No more data to read from socket" when executed from SQL Developer. I even tried with the latest JDBC driver from Oracle without much difference.
Would a better approach be to write some kind of stored procedure, that adds up all the single geometries by adding each call to SDO_AREA on each single geometry object - or what is the best approach?
Any advice would be appreciated.
Thanks in advance,
JacobHi
I am now trying to update all my spatial table with SRID's. To do this, I try to drop the spatial index first to recreate it after the update. But for a lot of tables I can't drop the spatial index. Whenever I try to DROP INDEX <spatial index name>, I get this error - anyone know what this means?
Thanks,
Jacob
Error starting at line 2 in command:
drop index BSSYS.STIER_00182_SX
Error report:
SQL Error: ORA-29856: error occurred in the execution of ODCIINDEXDROP routine
ORA-13249: Error in Spatial index: cannot drop sequence BSSYS.MDRS_1424B$
ORA-13249: Stmt-Execute Failure: DROP SEQUENCE BSSYS.MDRS_1424B$
ORA-29400: data cartridge error
ORA-02289: sequence does not exist
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 27
29856. 00000 - "error occurred in the execution of ODCIINDEXDROP routine"
*Cause: Failed to successfully execute the ODCIIndexDrop routine.
*Action: Check to see if the routine has been coded correctly.
Edit - just found the answer for this in MetaLink note 241003.1. Apparently there is some internal problem when dropping spatial indexes, some objects gets dropped that shouldn't be. Solution is to manually create the sequence it complains it can't drop, then it works... Weird error. -
Can we show 2 queries in a single query ?
Hi experts,
We require an output of a bex query.
But the output is coming in two different queries.
Is it possible to show two queries in a single query ?
Regards,
Nishuv.Hi Praveen,
We are using bex 3.x. I opened a workbook. in the view toolbar->Toolbars->Control Toolbox.
I clicked on this. A tool box came in the right side of the sheet.
The options which we got here are:
Exit Design mode
Properties
View code
Check box
Text box
Command button
Option button
List box
Combo box
Toogle button spin button
Scrool bar
Label
Image
More controls
Tool bar options.
Here i am not able to see the Analysis grid.
Is there anything more to be done to get this ?
Regards,
Nishuv. -
Getting result with single query
Hi,
I'm using db 10.2.0.1.0
I have a table emp_shift , with data like below
EmpCode Shift Effdate Default
1 SHFT1 02-jan-2012 N
1 SHFT2 04-jan-2012 Y
1 SHFT3 04-jan-2012 NSo if user inputs EmpCode and Effdate, based on that i've to take the latest record, with default = 'Y' (if any) else default 'N'
Suppose
Case 1 : Input Empcode:1 Date:10-jan-2012
Then i should get the below record
1 SHFT2 04-jan-2012 YCase 2 : Input Empcode:1 Date:03-jan-2012
Then i should get the below record
1 SHFT1 02-jan-2012 NI want this result with a single query, is this possible?
Thanks
DivyaHi Thank you both,
I'm trying this process through forms. and my forms version is 6i.
There where i'm trying the query with the cursor, i'm getting error
Encountered the symbol Order when expecting one of the following
.()...and my cursor is
Cursor cur_shft(vemp Varchar2,vdate Varchar2) is Select ESM_SHIFT_TYPE
from (Select ESM_SHIFT_TYPE from EMPLOYEE_SHIFT_MASTER
Where ESM_EMP_CODE = vemp
and ESM_EFF_DATE <= vdate
Order by ESM_EFF_DATE desc,Esm_Default desc)
Where rownum=1 ;Whats wrong? -
Multiple or Single Query?
I am trying building a ConstituencyMap of electoral
Constituencies each of which a couple of polling stations. I want
to output information containing the Name and Region of each
constituency and also a running total of the votes from each
polling station in that constituency until all polling stations in
that constituency have reported their results. Further more I will
use a query to find out which party won and change the color of the
cell to the parties assigned color.
My question is how do I get all this information in a single
cell. I do not know if I can use multiple query values in the same
logic. For example, my code to show the constituency name and
region is as attached. Being a novice in databases, I would rather
use multiple queries and try to add the results to the cell, but I
do not know if this is possible, I think a single query drawing
information from my multiple table would be the way to go, but this
would be a complex query.
I will appreciate any insight into this. ThanksAs well as Dan's suggestion for "Teach Yourself SQL in 10
Minutes" by
Ben Forta.
You can reference multiple queries. You just have to
reference the
record set data structure yourself, rather then relying on a
shortcut
such as <cfoutput query="aQuery">
A fully qualified record set reference is
queryName.columnName[row] OR
queryName['columnName'][row].
I.E.
<cfquery name="aQry".../>
<cfquery name="bQry".../>
<cfoutput>
#aQry.aColumn[1]# <---> #bQry['bColumn][2]
</cfoutput> -
Is it possible to show single dimension of measure value in Chart
Hi all,
By using BICS connection(BW-Bex Query), developed Application(dashboard) through sap design Studio 1.2 sp01. My requirement is Measure is Purchase OrderValue, and dimensions are x,y,z, and P. When Open application it has to show X-of Purchase Order values in one Chart,Y-of Purchase Order Value in another chart..like we need to show X,Y,Z and P values in different chart. How we can achieve by using single data source.
Thanks
RamHi Tammy,
Thanks for your quick reply. You are right.. we can create multiple views to show separately. but due to performance issue..is it possible to use single view to finish my requirement?
Explanation: i have 4 charts
1 chart: In X-Axis need's to show X-Values and in Y-Axis need's to show PO value
2 chart: In X-Axis need's to show Y-Values and in Y-Axis need's to show PO value
3 chart: In X-Axis need's to show Z-Values and in Y-Axis need's to show PO value
4 chart: In X-Axis need's to show P-Values and in Y-Axis need's to show PO value
here X,Y,Z,P are dimensions(fields).
unable to add image..
Thanks
Ram -
Query Design Strategies - servicing multiple reports from a single query
I was wondering if anyone knew of any good web resrouces (articles and such) to assist with Query Design Strategies. What I am specifically looking to do is replace multiple reports from the previous system with just views of a single query. So I was looking at grouping the existing reports that we are replacing into queries and creating views for each report.
The catch is that we will only be utilizing web reporting for report distribution, so we need to:
1. Use views as DataProviders to web templates
2. Broadcast views to users as links where they can see that particular view
Is this possible and does anyone have some info on how to do this?Lets say that 10 broadcasted reports all could use the same query but each in a different navigational state.
1. Can you navigate the query and save as a view and then set up a brodacast rule for that view?
2. Can a DataProvider in a web template be a view?
3. Can the BI Launcher iView take a view name in place of a query?
<prt_protcl>://<prt_server>/<bi_launcher>?TEMPLATE=TEST1&QUERY=TEST2 -
Update or select in a single query
Hi , I want to select or update from a single query. Can I do that ?
I tried Merge into, but it is for Update or Insert.
Can anyone help me please. I do not want to use stored Proc/function.userPrasad wrote:
I want to fire a update or merge statement inside a select SQL. Is there any way to do that ?Just to clarify:
It is possible to UPDATE based on a SELECT condition within SQL, i.e.,
UPDATE table1 t1
SET col1 = new_val
WHERE col2 IN (
SELECT col2
FROM table2 t2
WHERE t1.col1 = t2.col1
AND col1 = old_val);or to MERGE:
MERGE into table1 t1
USING (SELECT * FROM table2) t2
ON (t1.col1 = t2.col1)
WHEN MATCHED...
WHEN NOT MATCHED...Both of those will use a SELECT, and MERGE can UPDATE, INSERT, both or either one, or none.
Is that what you had in mind? -
Is it possible to open a query from sap menu favorite to excel?
Hi all
I have added a query in favorite . From the favorite in sap menu , i want to open the query in excel.
Is is possible?
Currently the query open in web.
Please revert back if you have any idea
Thanks
ajayHi Daya Sagar,
You said the query saved in favorite from query designer will open in browser and the one saved from analyzer will open in bex excel. But it does not work for me. It saves as web icon and both query is opening in browser.
Hi All,
The different story for me is I have problem of opening the web browser by running a query from favorite or user menu because in the url I have different Client. Is there any way to fix this url problem. Any one in this thread can help me on this issue and will be awarded. Thanks.
Raj
Maybe you are looking for
-
Dark picture on projector but okay on the lap top?
I have problems with dark pictures when using Air Mac and a projector. Everything is okay on the lap top, but the pictures shown by the projector are very dark. Have anyone out there a solution for this problem. I have talked to Apple support without
-
Rsync or other backup solution- single source multiple target?
Seems from http://www.linuxquestions.org/questions - ly-774225/ that I can't do what I want, but I thought I'd ask as well. My laptop hard disc is going to be backed up to two external hard discs (regular script). What I do right now is run two separ
-
Can we integrate credit card readers into a web app?
Most readers have companies that support them . . . I was wondering if it's possible to build a web app, through the online store, to utilize the plug in credit card readers for your phone??
-
When creating po, pop up error message 'address doesn't exist'.
when creating po via me21n, when click delivery tab screen, pop up error message dialog box 'address doesn't exist T001 wsu20 00010'. message no is 'am010'. then i was forced to exit transaction. ps: 'su20' is my plant, but in me21n, when selecting
-
Enum types not supported in jws
I'm using wls 10.3 and one of my java class has a property that used a java enum type and when I tried to run jwsc, I'm getting this error message: [jwsc] [ERROR] - Enum Types are not supported on a JWS: com.starcomsoft.pp.vo.RecordStatus [jwsc] C:\s