SQL & PL/SQL :: List Most Popular Product For Every State?

Feb 11, 2011

so here is the query : For every state, list the most popular product. Here is the query I have so far :

SELECT C.State, P.Product_Name, Count(*) cnt FROM Product P, Customer C, OrderTable O, LineItem L WHERE C.CID = O.CID AND O.OID = L.OID AND L.PID = P.PID GROUP BY C.State, P.Product_Name;

Result :
STATE PRODUCT_NAME COUNT(*)
---------- -------------------- ----------
New Jersey Computer 3
Texas Computer 1
New Jersey Speaker 2

I would need the result to only say New Jersey Computer and Texas Computer because I only want a list of the states with the product name that is sold the most in each state.All I need to do is have the query only select the product name with the max count for each state...

View 4 Replies


ADVERTISEMENT

List Products List Of Client Grouped By Type Of Product?

Dec 14, 2011

Im trying to list the products list of a client grouped by type of the product. Ex:

product type

prod.A acid
prod.B flavour
prod.C acid
prod.D cleaner
prod.E flavour

I want to list something as:

Acid

Prod.A
Prod.C

Cleaner

prod.D

Flavour

prod.B
prod.E

View 1 Replies View Related

SQL & PL/SQL :: Rank / DECODE Most Popular / Most Used Term

Mar 26, 2012

I have this code which simply gives me the count of term.

SELECT
OUA_ID

,COALESCE (MAX( DECODE( TERM, 0603, TERM_COUNT, NULL ) ), 0 ) "TERM_0603_CNT"
,COALESCE (MAX( DECODE( TERM, 0702, TERM_COUNT, NULL) ), 0 ) "TERM_0702_CNT"
,COALESCE (MAX( DECODE( TERM, 0705, TERM_COUNT, NULL ) ), 0 ) "TERM_0705_CNT"
,COALESCE (MAX( DECODE( TERM, 0707, TERM_COUNT, NULL ) ), 0 ) "TERM_0707_CNT"

FROM(

SELECT DISTINCT
OUA_ID, TERM_COUNT, TERM
FROM(
SELECT OUA_ID, TERM ,PROVIDER_CDE, COUNT(*) TERM_COUNT
FROM TABLE
WHERE PROVIDER_CDE = 'BILL'
GROUP BY OUA_ID, TERM, PROVIDER_CDE)) GROUP BY OUA_ID

Gives:

OUA_IDTERM_0603_CNTTERM_0702_CNTTERM_0705_CNTTERM_0707_CNT
32710 0 3 7 0
45726 2 0 1 0

Is there a way i could used the rank function (with decode) to only display the 1ST (First) and 2nd(Second) most used term per OUA_ID?

So i get this:

OUA_ID1st MOST USED2nd MOST USED
3271 705 702
45726 603 705

View 4 Replies View Related

SQL & PL/SQL :: Use Cartesian Product?

Mar 7, 2013

When to use Cartecian product???? is there any special cases to use cartecian product?

View 2 Replies View Related

SQL & PL/SQL :: Product Of Values In The Column?

Jul 29, 2010

how to find the product of the values in the column.. assume that the column has number(2) as its data type..

as we use sum(colname) for the sum of the values in the column there s no function to find the product.

View 3 Replies View Related

SQL & PL/SQL :: SUM Product By DATE By LOCATION

Dec 14, 2011

I am trying to query a Oracle database table that contains sample records like the one below...

DATE LOCN PROD1 PROD2
09/12/2011 L1 6 2
09/12/2011 L2 3 7
10/12/2011 L1 4 1
10/12/2011 L2 3 3
11/12/2011 L1 2 2
11/12/2011 L2 2 0
12/12/2011 L1 4 1
12/12/2011 L2 5 0

I am trying to use the Oracle Sum() to get a grouping by DATE, LOCATION, SUM(PROD1+PROD2) for DATE periods 10/12/2011 and 11/12/2011. Below is the desired end result.

DATE LOC1 LOC2
10/12/2011 5 6
11/12/2011 4 2

View 1 Replies View Related

SQL & PL/SQL :: Calculates Value Of Product Sold

Nov 25, 2011

Stored Procedure: Receives the MFR and PRODUCT identifying the product sold as well as the Quantity purchased by the customer.

 Calculates the value of the product sold (looks up the cost of the product in the products table and multiplies by the quantity sold)
 Returns the calculated value.

View 12 Replies View Related

PL/SQL :: Add Four More Column And Group By PRODUCT

Sep 28, 2012

I am new to PL/SQL environment.. ( USING PL/SQL Oracle)

SELECT TABLE1.PRODUCTID, TABLE1.TYPE , TABLE1.PRODUCT, TABLE2.#SOLD
FROM TR.TABLE1
INNER JOIN
PR.TABLE2
ON (TR. PRODUCTID = PRODUCTID )

Query result.

Product ID     Product          Type          #Sold
1     Fruit          Banana          2
2          Food          Rice          4
3          Food          Sugar          6
4          Fruit          Orange          2
5          Fruit          Apple          10
6          Food          Sugar          12
7          Food          Corn          3
8          Fruit          Apple          5
9          Fruit          Banana          2
10          Food          Sugar          1
11          Fruit          Banana          5
12          Food          Sugar          7

But would like to add Four More Column and group by by PRODUCT.Final Result will look like :

     {Product}     ,     {Type}     ,     {#Sold}     ,     0 to 3     ,     4 to 9     ,     >10          Total Sold     
          ,     {Corn}     ,     3     ,          ,          ,                    
          ,     {Rice}     ,          ,     4     ,          ,                    
          ,     {Sugar}     ,          ,          ,          ,     26               
     {Food}     ,          ,          ,          ,          ,               33     
          ,     {Apple}     ,          ,          ,          ,     15               
          ,     {Banana}     ,          ,          ,     9     ,                    
          ,     {Orange}     ,          ,     2     ,          ,                    
     {Fruit}     ,          ,          ,          ,          ,               36     }

View 9 Replies View Related

Getting Query To Display Only 150 And 162 As They Have Purchased Only One Product?

Jun 24, 2011

Is there a way to find customers purchased only single product from the following table?

cusno Product Date
----- ------ ----
121 ES 03/12
121 NT 30/12
131 ST 03/12
13 WT 04/12
150 ES 05/12
150 ES 06/12
150 ES 07/12
160 MN 05/12
160 ES 06/12
160 ES 07/12
162 NT 08/12

I need a query to display only 150 and 162 as they have purchased only one product.

View 2 Replies View Related

Windows :: Oracle 10g Installation Asking For Product.xml

Jun 18, 2013

I have oracle10g installable in .rar format. I have unzipped it and started installer through setup.exe file, but in the secnd step itself it is asking product.xml file location , i searched entire installables but could not find any thing with such name, installing this oracle 10g on windows 2003 server.

View 12 Replies View Related

SQL & PL/SQL :: Return Any Product That Doesn't Have TEST_UOM_GROUP

Jan 13, 2011

I have the following tables: -

CREATE TABLEtest_articles
(idNUMBER(9),
code VARCHAR2(20),
description VARCHAR2(40),
uom_group_id NUMBER(9),
in_exchange NUMBER(1) DEFAULT 0);
[code]....

However, I'd also like it to return any product that doesn't have a TEST_UOM_GROUP, for example the 'Bud'.I've hit a brick wall and just keep going around in circles and not acheiving the result I'm after!how to either change the SQL Query.

View 22 Replies View Related

Forms :: Microsoft Product And Oracle Application Are In One Server?

Jun 19, 2012

Bulk of Microsoft Application is running on windows server 2003 (OS) , is it possible to run parallel an oracle application on the same server .

View 4 Replies View Related

SQL & PL/SQL :: Searching PRODUCT Column Based Upon User Input?

Apr 30, 2010

I have table in Oracle with one column PRODUCT. Column PRODUCT have following values -

Account Management
Active Directory
Adobe Acrobat Reader
NT Account
Application Security

[code]....

I am designing application where I need to search for PRODUCT based upon user's input. Lets say user wants search on 'Laptop Account Broken'. I want to search for all products which contains any of words in user's input. So based upon user's input I want output like below.

Expected Output:

Account Management
NT Account
WebSite Account
HP Laptop

View 2 Replies View Related

Forms :: Frm-41211 Integration Error / SSL Failure Running Another Product

Jan 20, 2010

I have just migrated my database from oracle7 to Oracle9i. My application is still on forms 4.5 and reports 2.5.

i am having a problem after the migration. I am able to run my forms, but i cannot run my reports from my form (button). i am having the error : "frm-41211 integration error: SSL failure running another product". I want to mention that i am able to run the report from the report builder.

View 6 Replies View Related

PL/SQL :: Difference Between CROSS JOIN And Comma-notated Cartesian Product?

May 22, 2013

Oracle version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
OS: Linux Fedora Core 17 (x86_64)

I was practicing on Recursive Subquery Factoring based on oracle examples available in the documentation URL....I was working on an example which prints the hierarchy of each manager with his/her related employees. Here is how I proceed.

WITH tmptab(empId, mgrId, lvl) AS
(
    SELECT  employee_id, manager_id, 0 lvl
    FROM employees
    WHERE manager_id IS NULL
    UNION ALL
    SELECT  employee_id, manager_id, lvl+1
    FROM employees, tmptab
    WHERE (manager_id = empId)
[code]....

107 rows selected.

SQL> However, by accident, I noticed that if instead of putting a comma between the table names I put CROSS JOIN, the very same query behaves differently.That is, if instead of writing

UNION ALL
    SELECT  employee_id, manager_id, lvl+1
    FROM employees, tmptab
    WHERE (manager_id = empId)I write
. . .
UNION ALL
    SELECT  employee_id, manager_id, lvl+1
    FROM employees CROSS JOIN tmptab
    WHERE (manager_id = empId)I get the following error message
ERROR at line 4: ORA-32044: cycle detected while executing recursive WITH query

I remember, oracle supports both comme notation and CROSS JOIN for Cartesian product (= cross product). For example

SQL> WITH tmptab1 AS
  2  (
  3      SELECT 'a1' AS colval FROM DUAL UNION ALL
  4      SELECT 'a2' AS colval FROM DUAL UNION ALL
  5      SELECT 'a3' AS colval FROM DUAL
  6  ),
 [code]....

SQL> So if both comma notated and CROSS JOIN have the same semantic, why I get a cycle for the above mentioned recursive subquery factoring whereas the very same query works pretty well with comma between the table names instead of CROSS JOIN? Because if a cycle is detected (ancestor = current element) this means that the product with CROSS JOIN notation is generating some duplicates which are absent in the result of the comma notated Cartesian product.

View 9 Replies View Related

Forms :: FRM-41211 / Integration Error / SSL Failure Running Another Product

Feb 5, 2013

I have a form with a button for "Print Report " when I click button following error occurred :

FRM-41211 :integration error : SSL failure running another product

View 1 Replies View Related

Forms :: How To Avoid (no List Elements Defined For List Item) Error

Sep 27, 2011

I am creating the Dynamic list but when i am compiling the form it gives the compilation error "No list elements defined for the list item".

I can eliminate it by entering the dummy list element but this dummy value will be displayed at form run time.

View 1 Replies View Related

Index Is In Unusable State

Sep 1, 2010

I can see the error in alert log like

2437312:ORA-12801: error signaled in parallel query server P009
2437313:ORA-01502: index 'POS.XIETBK_POS_FACT_TRAN_DATE' or partition of such index is in unusable state

and tried to rebuild the index and i got following error.

ORA-14086: a partitioned index may not be rebuilt as a whole.

The table size for the index is large. we need to rebuild the hole index.

View 9 Replies View Related

SQL & PL/SQL :: Index Unused State

May 7, 2013

I made an Index Unused while doing some update by using sql developer right click 'Make unusealbe'. Now I need make it as useable.

marking as Usable. I have checked in all_indexes state is show as 'UNUSABLE'.

View 2 Replies View Related

PL/SQL :: Get CITY And STATE From Address

Jul 9, 2013

I have got a table where the site address is stored as follows - 

SOUTH PARK ROAD #822,,,,
HOLLYWOOD,FL,33021,,
USPO BOX 1111,,,,
PHILADELPHIA,PA,19178-3478,,
USNORTH AVE EAST,
P.O. BOX 1234,,,ELIZABETH,NJ,07207-6031,,
US12345 PARK SORRENTO SUITE 222,,,,
CALABASAS,CA,91302,,US 

I have got 2 fields to be populated from this - CITYSTATE How can I pick up the 5th and 6th field separated by the comma.

For example: -

Following output should be shown for the above recordsCITY  
 
STATEHOLLYWOOD       FLPHILADELPHIA        PAELIZABETH       NJCALABASAS       CA

View 3 Replies View Related

Session Inactive State?

Jul 1, 2012

want to know the following

1. when the oracle session changed from active to inactive?
2. what is the time for active session?
3. session is changed to inactive from active. but it is still showing in v$session.
4. in v$session, can i see the ipaddress of client machine ?

View 6 Replies View Related

Forms :: Integration Error - SSL Failure Running Another Product With HP Deskjet D2680?

Sep 14, 2011

"Integration error: SSL failure running another product" with HP Deskjet D2680.We are using 10gR2, Forms6i, and Report6i. The server is Windows 2003 Server, and the OS of the printer is XPIn one of our module, upon calling one report we always encounter Integration error: SSL failure running another product. Sometimes when we do not encounter it, the spooling takes too much time and it takes 6minutes just to print the first page of the report, succeeding pages takes 2-3minutes in interval.

At first we thought that the memory of the PC is the problem, but we tried to connect it to a 2gig RAM Win7 laptop, another laptop with 1gig RAM XP, and a 1g RAM Desktop. We tested 5 computers but the same problem occurs.

The problem is not encountered after we tried other HP Printer(HP 3940, 6988, & D4360). I just want to know the problem with the HP Deskjet D2680.

View 2 Replies View Related

Networking And Gateways :: Installation Product Specific Prerequisite Checks Window?

Apr 18, 2010

in oracle instalation when Product-Specific Prerequisite Checks window appears it show me theres a warning with checking network configration as shown in pic.theres a sites says that its not necessary to make it succeeded and its ok to leave it. should i leave this warning or it should be succeeded?

View 9 Replies View Related

SQL & PL/SQL :: Writing Procedure In User 2 Schema Accessing Table Product - Not Compiled?

Dec 17, 2010

I have got 2 users as user1 and user2.I have used the following statements from user 'user1':

create role GENEVAOBJECTS;
grant select, insert, update, delete on PRODUCT to GENEVAOBJECTS;
grant GENEVAOBJECTS to user2;

In the above statements, product is a table. Now, I could able to access this table from user 'user2'. But however if I write a procedure in user2 schema accessing the table product, then the procedure is not getting compiled.

create or replace procedure test_prc as
v_test number(9);
begin
select product_id into v_test
from PRODUCT where rownum=1;

[code]...

why I cannot access that table from procedure?

View 8 Replies View Related

Forms :: FRM-30351 / No List Elements Defined For List Item

Oct 30, 2011

DECLARE
CURSOR GRP IS
SELECT RowNum rn, Letter_Group_ID||'-'||A_Desc AName,Letter_Group_ID
FROM Hrs_Group;
BEGIN
Clear_list('Letter_Group_ID');
FOR I IN GRP LOOP
Add_List_Element('Letter_Group_ID',I.rn,I.AName,I.Letter_Group_ID);
end loop;
END;

FRM-30351: No list elements defined for list item.

List LETTER_GROUP_ID

View 4 Replies View Related

Forms :: Restrict User To Enter Serial Numbers Of Product In 3 Level Block

Apr 24, 2012

I have a sale invoice form with 3 data blocks.

Data block 1- master_blk : For date/customer of sale invoice
Data block 2- detail_blk1 (detail of the master block - For products and qty)
Data block 3- detail_blk2 (detail of DETAIL_BLK1 For entering serial numbers of products)

My requirement is that whatever quantity user enter in data block 2 against each product he must enter equal number of serial numbers of that product in data block 3.

For this I have created on item (cnt_iteml : to count product's serial numbers in block3 ) in data block 2, and on summary item (t_serial_no ) in block3.

Whenever user changes in quantity, cnt_iteml: item is populated with t_serial_no in block3 of that product by following trigger on quantity column.

POST-Change Trigger ( quantity column )

:stock_transactions.cnt_itl:=:serial_numbers.t_serial_no;

Following trigger is written on block level at data block-3 to populate cnt_iteml with t_serial_no.
PRE-RECORD

IF GET_BLOCK_PROPERTY('SERIAL_NUMBERS',STATUS) IN ('CHANGED') THEN
:stock_transactions.cnt_itl:=:serial_numbers.t_serial_no;
END IF;

Above triggers are fulfilling my requirement except following condition.

If user after entering serial numbers in block 3 and without saving goes back to block2 and try to navigate to another record he gets a message asking him to save changes by forms. At this time if user presses no then cnt_itl item is not been populated with t_serial_no item's value.

What I want in above condition is that if user was inserting new record cnt_it item should be populated with 0, so that he shouldn't be able to save this record. And If he was updating then cnt_itl item should be populated with actual no of records in database against that product.

View 2 Replies View Related

SQL & PL/SQL :: RESTRICT_REFERENCE Changing A Database State

Mar 24, 2010

When i am writing a function (Stand alone or inside a Package) i know what i am writing, i know weather i am changing a Package state or weather i am changing a Database State. So what is the use for giving a PRAGMA RESTRICT_REFERENCE?

as for the other PRAGMAs EXECPTION_INIT is needed to Specify an error name to a specifiec error number so that i can use the error name to handle the exception. AUTONOMOUS_TRANSACTION is used to execute the SQL Operation inside a Block as a child Transaction.SERIALLY_REUSABLE states that a package variable doesnot persists throughout the session.

RESTRICT_REFERENCE states that the code should not do the following
RNPS : Read no package state,
WNPS : Write no package state
RNDS : Read no database state
WNDS : Write no database state

what is there to state as i know what my code is doing.

without specifing EXECPTION_INIT, AUTONOMOUS_TRANSACTION or SERIALLY_REUSABLE i cannot get a handler for an exception which doesnot have a handler, i cannot execute SQL Operations from inside the CODE autonomously or i cannot reuse the package variable, but without the RESTRICT_ REFERENCE is can ensure that my code in not doing (RNPS,WNPS,RNDS,WNDS).

View 7 Replies View Related

Oracle Solid State Disk

Feb 1, 2013

I understand the architecture of solid state drives favor different types of I/O. Oracle 11g introduced the database flash cache which allows flash storage to be used as a secondary cache. With database flash cache serving as a secondary cache to my Oracle buffer cache.

My understanding is I need to config two database parameters DB_FLASH_CACHE_FILE and DB_FLASH_CACHE_SIZE. If i want to have certain tables/indexes to take advantage of this extra cache I would set the value KEEP within the parameter.

Is there anything that needs to be done to the tablespaces / datafiles.

View 1 Replies View Related

PL/SQL :: Existing State Of Package Has Been Discarded

Nov 2, 2012

I am getting the following error only for the ""first execution"", even the package is in "valid" state. If the execute the same package again "second execution", it runs ok.

usually we complie all the "invalid objects" in the schema when we move the code to TEST or PRE-PROD env.

but i am getting the following error, even if the package is in "valid state".

ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package "TEST_OWNER.TEST_PKG" has
been invalidated
ORA-04065: not executed, altered or dropped package
"TEST_OWNER.TEST_PKG"
ORA-06508: PL/SQL: could not find program unit being called:
"TEST_OWNER.TEST_PKG"
ORA-06512: at line 2I have gone through the following thread, blu explained the cause of this error,
but do we get this error even when the package is in "valid" state too?

Re: When should be package invalidated?

View 4 Replies View Related

ORA-04068 - Existing State Of Packages Has Been Discarded

Feb 4, 2011

We are experiencing an issue with ORA-04068: existing state of packages has been discarded. We're running Oracle 10.2.0.4 on Solaris 10.

I'll provide the timeline of what occurred:

1.) Last night during a maintenance window I recompiled a package and package body. I ran "create or replace" statements from a script via sqlplus to recompile both package and package body. Because I am required to do all DDL under my own login (and not the schema owner login) the scripts require that the schema name be included in the "create or replace" statements. Otherwise an object will be incorrectly created in my schema. This is what happened with the package body. I discovered this when the package body would not compile.

2.) I ran a "drop package body" statement to drop the package body from MY schema.

3.) I added the proper schema name to the script and recompiled both the spec and body under the proper schema.

4.) I ran a script to check for any invalid objects under the application user schema. There were none.

5.) During the night a batch process ran which executed the package. There were several failures with the error ORA-04068: existing state of packages has been discarded.

6.) During the early AM today the error stopped. Not knowing this at the time and believing that the issue was still occurring I began searching the internet for information regarding this issue. One site I found said this could be due to DDL being done on the object (which was the case for us) and there could be an entry in the shared pool marked as invalid which our application's session may be accessing. It recommended running "alter package recompile" for the spec and body. I did this but it seems to have triggered the event again.

I also ran utlrp.sql.

I found some information suggesting the use of DBMS_SESSION.MODIFY_PACKAGE_STATE and/or RESET_PACKAGE but I'm not seeing mention of the risks/implications.

I can verify that the object is no longer in my schema and that the proper object owner has no invalid objects. I am not sure what to do to resolve the issue or keep it from occurring again.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved