How to build a SQL for this logic.
HelloI have a requirement like, I need to derive a column with a calculation.
Here is the psedocode,
number of occurrence (deptno = 10) / count (deptno = 10)
Expected result:
If the deptno = 10 occurs 3 times in the table, then at the time of fist should be the calcuation
second 1/3, 2/3 of the time, the third time 3/3 and so on.
How can I build in a sql query. Help, please.
Any help will be appreciated with points.
Thank you.
Try this.
SELECT LEVEL / CNT CALC
FROM (SELECT COUNT (*) CNT
FROM EMP
WHERE DEPTNO = 10)
CONNECT BY LEVEL <= CNT
G.
Tags: Database
Similar Questions
-
How to build a formula for this logic.
Hello
I have a requirement like, I need to derive a column with a calculation.
Here is the psedocode,
number of occurrence (deptno = 10) / count (deptno = 10)
Expected result:
If the deptno = 10 occurs 3 times in the table, then at the time of fist should be the calcuation
second 1/3, 2/3 of the time, the third time 3/3 and so on.
How can I build this in a form/report/RPD design. Help, please.
Any help will be appreciated with points.
Thank you.The overall operation will help you do this, i.e. RCOMPTE, C.V.
This should work:
C.V. (CASE WHEN deptno = 10 THEN 1 ELSE END 0)
to give you the current account lines where deptno = 10
Then you can divide ths by
SUM (CASE WHEN deptno = 10 THEN 1 ELSE END 0)
don't know if that will be 100% or not, but try the first statement so you can see the overall work running, then try the Division in order to see if it works:
C.V. (CASE WHEN deptno = 10 THEN 1 ELSE END 0) / SUM (CASE WHEN deptno = 10 THEN 1 ELSE END 0)
-
How to write a SQL for this condition?
I have a table with columns v_sub, v_visit, and T_DATE and the structure is like this
v_sub v_visit T_DATE
1 visit-1 01 - mar - 09
1 visit-2 05 - mar - 09
1 visit-3 17 - mar - 09
2-visit-1-4 February 09
2 visit-2 12 - mar - 09
2 visit-3 20 - mar - 09
I want to write a query that control weather it is in chronological order or not. (for v_sub, v_visit and T_DATE must be in chronological order as above)
and I want to check the condition as below:
v_sub v_visit T_DATE
1 visit-1 01 - mar - 09
1 visit-2 5 February 09
1 visit-3 17 - mar - 09
2-visit-1-4 February 09
2 visit-2 12 January 09
2 visit-3 20 - mar - 09
Thanks in advanceUse the LAG function to get previous date
SQL> -- sample data SQL> with t 2 as 3 ( 4 select 1 v_sub, 'visit-1' v_visit, to_date('01-mar-09','dd-mon-yy') v_date from dual union all 5 select 1, 'visit-2', to_date('05-mar-09','dd-mon-yy') from dual union all 6 select 1, 'visit-3', to_date('17-mar-09','dd-mon-yy') from dual union all 7 select 2, 'visit-1', to_date('04-feb-09','dd-mon-yy') from dual union all 8 select 2, 'visit-2', to_date('12-mar-09','dd-mon-yy') from dual union all 9 select 2, 'visit-3', to_date('20-mar-09','dd-mon-yy') from dual 10 ) 11 -- end of sample data 12 select v_sub, v_visit, v_date, lag(v_date) over(partition by v_sub order by v_visit, v_date) v_previous_date 13 from t 14 / V_SUB V_VISIT V_DATE V_PREVIOU ---------- ------- --------- --------- 1 visit-1 01-MAR-09 1 visit-2 05-MAR-09 01-MAR-09 1 visit-3 17-MAR-09 05-MAR-09 2 visit-1 04-FEB-09 2 visit-2 12-MAR-09 04-FEB-09 2 visit-3 20-MAR-09 12-MAR-09 6 rows selected.
Now you can check if the previous_date is less than T_DATE
-
How to build botan lib for BlackBerry 10?
Hello
I'm porting some proxy software - as in 10 BlackBerry platform then I found it requries botan 1.1 +.
(25,10):#include
(26,10):#include (29,16):using namespace Botan; etc.
This is the homepage of botan: http://botan.randombit.net/
y at - it advice on how to use this lib in my application of cascades?
Botan has a configure.py in the downloaded tar, works fine on linux, but how to build targeted qnx lib?
Thank you.
Unfortunately you cannot use the series of development because it requires "version 1.11.0 and require a compatible for most C ++ 11 3.1 Clang compiler or GCC 4.7.
1.10 stable series should be ok.
-
How to run wfstatus.sql for i-expenses
How to run wfstatus.sql i-expenses in EBS 11i.Select this check box, hope it helps.
How to find and solve the reports on Internet expenditures within workflow [ID 185004.1]
How wfstatus.sql to run on a statement of expenses Internet [134895.1 ID]
-
How you "allow by program for this purpose?
I saw 1 million forum posts where people want to activate programming their PDF files for comments, and the answer is: use LiveCycle. We plan to buy LiveCycle for our server JUST for this purpose, because it doesn't seem to be another way to do it. Before we do that, I want to know how it would work. Since I did not livecylce, I can't very well search and understand it, and I don't see any free downloads of the trial. Can someone explain how would you do this task? On the other hand, is not the pdf document open standard? Is it possible to change the pdf file "under the hood" to allow him to comment, without assistance from the Acrobat menu item?
TO apply rights uage to a document PDF programmatically, see named apply the usage rights to PDF Documents located at the following ADDRESS:
http://livedocs.Adobe.com/LiveCycle/8.2/programLC/programmer/help/000411.html
It will explain what to do and will lead you to the following Java code example:
/*
* This Java Quick Start uses the following JAR files
* 1. adobe-reader-extensions-client.jar
* 2. adobe-livecycle-client.jar
* 3. adobe-usermanager-client.jar
* 4. adobe-utilities.jar
* 5. jbossall-client.jar (use a different JAR file if LiveCycle ES is notdeployed
* on JBoss)
*
* These JAR files are located in the following path:
*
/Adobe/LiveCycle8/LiveCycle_ES_SDK/client-libs *
* For complete details about the location of these JAR files,
* see "Including LiveCycle ES library files" in Programming
* with LiveCycle ES
*/
import com.adobe.livecycle.readerextensions.client.*;
import java.util.*;
import java.io.File;
import java.io.FileInputStream;
import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
public class ApplyUsageRights{
public static void main(String[] args) {
try{
//Set connection properties required to invoke LiveCycle ES
Properties connectionProps = new Properties();
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://localhost:1099");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
//Create a ServiceClientFactory object
ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
//Create a ReaderExtensionsServiceClient object
ReaderExtensionsServiceClient reClient = new ReaderExtensionsServiceClient(myFactory);
//Retrieve the PDF document to which to apply usage rights
FileInputStream fileInputStream = new FileInputStream("C:\\Adobe\\Loan.pdf");
Document inputPDF = new Document(fileInputStream);
//Create a UsageRight object and specify specific usage rights
UsageRights useRight = new UsageRights();
useRight.setEnabledDynamicFormFields(true);
useRight.setEnabledComments(true);
useRight.setEnabledFormFillIn(true);
useRight.setEnabledDigitalSignatures(true);
//Create a ReaderExtensionsOptions object
ReaderExtensionsOptionSpec reOptions = new ReaderExtensionsOptionSpec();
//Set the usage rights
reOptions.setUsageRights(useRight);
reOptions.setMessage("This is a Rights-Enabled PDF Document");
//Apply usage rights to a PDF document
Document rightsEnabledPDF = reClient.applyUsageRights(
inputPDF,
"RE2",
null,
reOptions);
//Create a new PDF file that represents the rights-enabled PDF document
File resultFile = new File("C:\\Adobe\\Critique5.pdf");
rightsEnabledPDF.copyToFile(resultFile);
}catch (Exception e) {
e.printStackTrace();
}
}
}
-
See the end of this message for details on the call
just-in-time (JIT) debugging instead of this dialog box.Loading assemblies *.
mscorlib
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.233 (RTMGDR.030319 - 2300)
Code: file:///D:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
AdApplicationFrame
Assembly version: 0.0.0.0
Win32 version: 3.2.23.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AdApplicationFrame.DLL
----------------------------------------
msvcm90
Assembly version: 9.0.30729.4926
Win32 version: 9.00.30729.4926
Code: file:///D:/Windows/WinSxS/amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_08e1a05ba83fe554/msvcm90.dll
----------------------------------------
Acdbmgd
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcdbMgd.DLL
----------------------------------------
System
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.233 built by: RTMGDR
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
AdWindows
Assembly version: 3.2.23.0
Win32 version: 3.2.23.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AdWindows.DLL
----------------------------------------
PresentationFramework
Assembly version: 4.0.0.0
Win32 version: 4.0.30319.233
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.dll
----------------------------------------
WindowsBase
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.233 built by: RTMGDR
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll
----------------------------------------
PresentationCore
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.233 built by: RTMGDR
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_64/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll
----------------------------------------
System.Xaml
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xaml/v4.0_4.0.0.0__b77a5c561934e089/System.Xaml.dll
----------------------------------------
System.Core
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.233 built by: RTMGDR
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.233 built by: RTMGDR
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
PresentationFramework.Aero
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.Aero/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.Aero.dll
----------------------------------------
System.Drawing
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Acmgd
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/Acmgd.DLL
----------------------------------------
System.Configuration
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319 - 0100)
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
AcWindows
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcWindows.DLL
----------------------------------------
AcCui
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcCui.DLL
----------------------------------------
WindowsFormsIntegration
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsFormsIntegration/v4.0_4.0.0.0__31bf3856ad364e35/WindowsFormsIntegration.dll
----------------------------------------
AcWindows.resources
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/en-US/AcWindows.resources.DLL
----------------------------------------
ContextualTabSelectorRules
Assembly version: 0.0.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcWindows.dll
----------------------------------------
System.Windows.Forms
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
ManagedMC3
Assembly version: 5.8.0.0
Win32 version: 5.8.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/ManagedMC3.DLL
----------------------------------------
UIAutomationProvider
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/UIAutomationProvider/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationProvider.dll
----------------------------------------
AcWelcomeScreen
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcWelcomeScreen.DLL
----------------------------------------
AcLayer
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcLayer.DLL
----------------------------------------
AcLayer.resources
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/en-US/AcLayer.resources.DLL
----------------------------------------
AcButterflyExt
Assembly version: 1.0.0.23
Win32 version: 1.0.0.23
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcButterflyExt.DLL
----------------------------------------
AcButterflyExt.resources
Assembly version: 1.0.0.23
Win32 version: 1.0.0.23
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/en-US/AcButterflyExt.resources.DLL
----------------------------------------
AcDialogToolTips
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcDialogToolTips.DLL
----------------------------------------
AcDialogToolTips.resources
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/en-US/AcDialogToolTips.resources.DLL
----------------------------------------
Accessibility
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
BomEXPORT
Assembly version: 1.0.0.0
Win32 Version: 1.0.0.0
Code: file:///C:/BomEXPORT/iBOM-AutoCAD-SOURCE/BomEXPORT/bin/Debug/BomEXPORT.dll
----------------------------------------
AcCustomize
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcCustomize.DLL
----------------------------------------
AcCustomize.resources
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/en-US/AcCustomize.resources.DLL
----------------------------------------
AcMrUi
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcMrUI.DLL
----------------------------------------
AcMrUi.resources
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/en-US/AcMrUi.resources.DLL
----------------------------------------
CCRM
Assembly version: 18.2.0.0
Win32 version: 18.2.51.0.0
Code: file:///C:/Autodesk/AutoCAD%202012%20-%20English/AcMr.DLL
----------------------------------------
System.Runtime.Serialization
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319 - 0100)
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll
----------------------------------------
PresentationFramework.Luna
Assembly version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
Code: file:///D:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.Luna/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.Luna.dll
----------------------------------------
ADODB
Assembly version: 7.0.3300.0
Win32 version: 7.10.6070
Code: file:///D:/Windows/assembly/GAC/ADODB/7.0.3300.0__b03f5f7f11d50a3a/ADODB.dll
----------------------------------------
iBOM-AutoCAD
Assembly version: 1.0.0.0
Win32 Version: 1.0.0.0
Code: file:///C:/BomEXPORT/iBOM-AutoCAD-SOURCE/BomEXPORT/bin/Debug/iBOM-AutoCAD.dll
----------------------------------------JIT debugging *.
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
permit.For example:
When JIT debugging is enabled, an unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.Hello
The question you have posted is related to professional level support. Please visit the below mentioned link to find a community that will support what ask you:
http://social.msdn.Microsoft.com/forums/en/category/VisualStudio
-
How can I write the SQL for this result?
Hello my dear,
Here first of all the script.
the data areCREATE TABLE ACC_TEST( AD_ID NUMBER, AD_NAME VARCHAR2(50), AD_SPM_ID NUMBER); /
I need the following result, when passing a value of Ad_Id. For example I go to 142 then result must beInsert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (136,'Saleh Ahmed',129); Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (142,'Hamidur Rahman',136); Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (124,'Jasim Uddin',null); INSERT INTO ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) VALUES (129,'Sazib',124);
Database 10 G XESelect Ad_Id,Ad_Name From.. ... where ad_id=142 Ad_Id Ad_Name 136 Saleh Ahmed 129 Sazib 124 Jasim Uddin If I Pass Ad_Id=136 Then Result Should Be Ad_Id Ad_Name 129 Sazib 124 Jasim Uddin If I Pass Ad_Id=129 Then Result Should Be Ad_Id Ad_Name 124 Jasim Uddin
Any help will be usefulHello
HamidHelal wrote:
WoW! You are totally my point. How do you understand that? lGuess luck. Guessing is generally not the best way to solve problems. It is generally faster and more reliable to say exactly what you want, as well as give an example.
fallen little more that I want to know, if I want to restrict the output not more then 2, which would be sql?
Now, you're not even giving for example!
Maybe you want something like this:SELECT ad_id , ad_name FROM acc_test WHERE LEVEL BETWEEN 2 AND 3 -- Changed START WITH ad_id = :target_ad_id CONNECT BY ad_id = PRIOR ad_spm_id ;
which will show just the mother and grandmother of the given line.
I work with the developer of forms a lot. Knowledge of SQL is like sql oracle (9i cerfitication) book. But this type of sql is not available here.
where can I learn this type of sql? SQL different then regular?Certification is another matter entirely.
There are books and web sites dealing with more advanced techniques. Sorry, I don't know any good enough to recommend. Some authors (such as Tom Kyte) are always good.Here are a few sites that explain CONNECT BY queries:
http://www.adp-GmbH.ch/ora/SQL/connect_by.html
http://www.oradev.com/connect_by.jsp -
Need Sql querry for this logic
Empname MJ sex desg salary managerid dept ID
2 B 2 JANUARY 12 M 10 20000 B1 SS
3 C 2 JANUARY 12 M 90000 10 C1 SS
4 D JANUARY 2, 12 M 15000 20 D1 SS
5 E 2 JANUARY 12 F 20 14245 E1 SS
6 JANUARY 2 F 12 F 2458 20 F1 SS
7 G 2 JANUARY 12 F 4556 20 G1 SS
8 JANUARY 2: 12 F SS 20 789 H1
Write an sql to get the name of the employee who received the highest wages? It is the question of the interview...select empname from employees where salary in (select max(salary) from employees);
-
Hi, I tried to figure out how to extract data from my SQL Server databases and reading messages and to do some tests with examples, I can get data connection type in my SQL server, but so far nothing helps. Is it possible to get data from a SQL Server database without using the database connectivity Toolkit? and if so, how? are there whitepapers and/or examples of this? So far, I can't find something that works. Thank you.
Jesse - what is your reason for not using the database connectivity Toolkit? It is by far the best way to recover the data.
-
How the group using SQL for the desired output.
Hi all
I am currently using oracle 10.2.0.4.0
Create a table script:
INSERT statement:CREATE TABLE FORTEST ( gpno VARCHAR2(10 BYTE), classnumber VARCHAR2(10 byte), age_min NUMBER, age_max NUMBER, amount NUMBER)
power required:insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 01,0,29,1) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 01,30,35,2) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 01,36,40,3) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 02,0,29,1) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 02,30,35,2) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 02,36,40,5) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 03,0,29,1) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 03,30,35,2) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 03,36,40,3) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G124' , 01,0,29,1) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G124' , 01,30,35,2) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G124' , 01,36,40,3)
as for gpno g123, classnumber 1 and 3, the rates are the same in all the age_min and age_max they need to be grouped.gpno classnumber age_min age_max amount G123 1,3 0 29 1 G123 1,3 30 35 2 G123 1,3 36 40 3 G123 2 0 29 1 G123 2 30 35 2 G123 2 36 40 5 G124 1 0 29 1 G124 1 30 35 2 G124 1 36 40 3
even if gpno 123 classnumber 2 has the same rates as the classesnumber 1 and 3 for the age groups 0 to 29 and 30 to 35,
rates are different for ages 36 to 40. so it should not be placed together. How can I do this in SQL
any help is appreciated.
Thanks in advance.Hello
Thorny problem!
Unfortunately, LISTAGG was created to the Oracle 11.2. About half of the complexity here is the aggregation of chain, i.e. forming the list of the classnumbers, as '1.3', using only functions available in Oracle 10.2.
Here's a solution:
WITH got_gpno_classnumber_cnt AS ( SELECT gpno, classnumber, age_min, age_max, amount , COUNT (*) OVER ( PARTITION BY gpno , classnumber ) AS gpno_classnumber_cnt FROM fortest -- WHERE ... -- If you need any filtering, this is where it goes ) , pairs AS ( SELECT a.gpno , a.classnumber , MIN (b.classnumber) OVER ( PARTITION BY a.gpno , a.classnumber ) AS super_classnumber FROM got_gpno_classnumber_cnt a JOIN got_gpno_classnumber_cnt b ON a.gpno = b.gpno AND a.age_min = b.age_min AND a.age_max = b.age_max AND a.amount = b.amount AND a.gpno_classnumber_cnt = b.gpno_classnumber_cnt GROUP BY a.gpno , a.classnumber , b.classnumber HAVING COUNT (*) = MIN (a.gpno_classnumber_cnt) ) , got_rnk AS ( SELECT DISTINCT gpno, classnumber, super_classnumber , DENSE_RANK () OVER ( PARTITION BY gpno , super_classnumber ORDER BY classnumber ) AS rnk FROM pairs ) , got_classnumbers AS ( SELECT gpno, classnumber, super_classnumber , SUBSTR ( SYS_CONNECT_BY_PATH (classnumber, ',') , 2 ) AS classnumbers FROM got_rnk WHERE CONNECT_BY_ISLEAF = 1 START WITH rnk = 1 CONNECT BY rnk = PRIOR rnk + 1 AND gpno = PRIOR gpno AND super_classnumber = PRIOR super_classnumber ) SELECT DISTINCT g.gpno , c.classnumbers , g.age_min , g.age_max , g.amount FROM got_gpno_classnumber_cnt g JOIN got_classnumbers c ON c.gpno = g.gpno AND c.classnumber = g.classnumber ORDER BY g.gpno , c.classnumbers ;
Out (just as you requested):
GPNO CLASSNUMBERS AGE_MIN AGE_MAX AMOUNT ---------- --------------- ---------- ---------- ---------- G123 1,3 0 29 1 G123 1,3 30 35 2 G123 1,3 36 40 3 G123 2 0 29 1 G123 2 30 35 2 G123 2 36 40 5 G124 1 0 29 1 G124 1 30 35 2 G124 1 36 40 3
-
Where to find or how to create LKM SQL FOR SQL?
Hello
I m very big thing back to ODI.
My problem is that I have to map a table in my DB ORACLE in a CSV file. So I created an Interface in my editor ODI and
1 checked 'target different stop.
2. now, it says "staging area is different from the target. In order to load data from the staging area to the target, you must select a multiple on the target connection revenge or a LKM on the staging area. »
3. in my goal, I use an IKM SQL append
Can anyone tell
1. how this 'IKM SQL append"multi connection
or
2 should. what LKM I use for my rest area. And where can I find that LKM. (Right now I have that LKM Sql file I have some previous draft.)
Thanks in advance :)
Vikas.Hi Vikas
You can import the default KM (LKM, IKM, sewing, RKM) to oracleodi/xmlreference and then duplicate the imported KM (LKM or IKM). Then see all the steps inside he make changes in the steps needed if you want according to your requirement. Do not try to encode any value in your KM.
Thank you
-
I have a project named FooLibrary within a workspace. And in this project is a single file that exposes a single class. I put this project of type 'Library' (project-> Application-> project properties). Build it and the world is a happy place. Then, I create a new workspace and a new project within the workspace. I add the file FooLibrary.jar (produced by the above) to this project. Then I add another project to that workspace, should depend on the project that has FooLibrary.jar in it. I add an instance of the FooLibrary class in this project. I build it and it builds. Then, when I run, I hit a check error 1610.
Curiously, if, instead of making FooLibrary a library, I don't type Application CLDC (the default type). then when I compile FooLibrary I get warnings, but absolutely everything else works.
Am I missing something obvious here, or am I really confused on the world?
As always, thanks for everything!
-Henry
If you want to make a library - add relevant source files to a project of type 'Library' in JDE and compile it to jar file.
After that - delete file cso and csl of cod this jar file.
And try to import this jar in the project properties dialog box.
-
How to build a SQL query to print ranges of week of a month
Hi gurus!
I have a requirement to create a query to display the times of week of a month.
The entries will be Year and month.
The result should be something like this:
If the year = 2009 and month = June
The SQL query should return the following:
June 1, 2009-June 6, 2009
June 7, 2009 to June 13, 2009
June 14, 2009-June 20, 2009
June 21, 2009-June 27, 2009
June 27, 2009 to June 30, 2009
I'm confused how to proceed. Please help me. Any help would be appreciated grately.
Thank you
AhmedHello
This might help (the exit is not exactly the same):
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0 Connected as hr SQL> SQL> SELECT TRUNC(to_date('01-Jun-2009'), 2 'D') + 7 * (LEVEL - 1) AS START_DATE, 3 TRUNC(to_date('01-Jun-2009'), 4 'D') + 7 * (LEVEL - 1) + 6 AS END_DATE 5 FROM dual 6 CONNECT BY LEVEL <= 4; START_DATE END_DATE ----------- ----------- 31/05/2009 06/06/2009 07/06/2009 13/06/2009 14/06/2009 20/06/2009 21/06/2009 27/06/2009 SQL>
Kind regards
-
How to add PL/SQL for AppModule processes
Hi community I try to add a PL/SQL APPMODULE process with the answer for the view controller.
Thank you.Hi Peter
Use this guide [http://download-west.oracle.com/docs/cd/B32110_01/web.1013/b25947/bcadvgen.htm#sm0297]
Good luck
Maybe you are looking for
-
Sierra of BONE &; readers of WD NAS
Hello I ask a question early really, as opposed to a question real glitch/failure. When El Capitan arose last year, set up has resulted in a number of fails with my SIN of WD readers. Namely that the operating system simply could not know them with
-
I backed up my iPhone 3GS on iTunes. Back up seemed to go OK. ITunes then prompted me to update the iOS that I did. The update failed. My phone broke. The only option available was to restore to factory settings I've done. The back up I had made was
-
I got a new modem and the router and now I can't print wireless.
I have a Photosmart 8450 printer. My operating system is Windows7. I tried to follow the Scan doctor, but I guess I'm not tech savy enough to understand. It worked fine before the new modem and the router. She is 'offline' and I can't understand
-
Windows xp professional operating systems, Windows Security Center says "Virus Protection is OFF", M/S Security Essentials says its aid "WE and Uptodate" Please
-
How to uninstall windows vista?
I do not like vista and want to install windows xp on my computer. How to uninstall vista?