473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Oracle Query problem...

45
I have got some problem with my sql query in oracle 9i.
i m trying to stop several occurances of same Do_No.
In the following example (Example1)shows that each Do_No have different MR_No and different MR_Amount.The problem is, we can see that same DO_No occourars several times.But i want it once only when show report on screen(see Example2).

Exmple:1
Query:
select
v_do_sales6.do_no,
v_mreceipt1.mr_no,
v_mreceipt1.amount
from
v_do_sales6,v_mreceipt1 where v_do_sales6.do_date between '01-jun-09' and '30-jun-09' and
v_mreceipt1.DISTRIBUTOR_CODE=v_do_sales6.distribut or_code and
v_do_sales6.distributor_code='S051'

Output:
Do_No MR_No MR_Amount
-----------------------------------------------------------
01 101 5000
01 102 4500
01 103 5600
01 104 6800
01 105 5005
02 106 7250
02 107 3060
02 108 8000

Exmple:2
Output

Do_No MR_No MR_Amount
-----------------------------------------------------------
01 101 5000
102 4500
103 5600
104 6800
105 5005
02 106 7250
107 3060
108 8000

Can anybody Please help me..... i need it early

Thanks in advance
Aug 17 '09 #1
7 2613
OraMaster
135 100+
Hi,

Please check and run the below SQL

Expand|Select|Wrap|Line Numbers
  1. SELECT DECODE (seq, 1, do_no, NULL) do_no, mr_no, mr_amt
  2.   FROM (SELECT ROW_NUMBER () OVER (PARTITION BY mst.do_no ORDER BY mst.do_no)
  3.                                                                           seq,
  4.                mst.do_no, dtl.mr_no, dtl.mr_amt
  5.           FROM v_do_sales6 mst, v_mreceipt1 dtl
  6.          WHERE mst.do_no = dtl.do_no)

While writing this SQL I have made DO_NO column as a Primary Key in v_do_sales6 and Foreign Key in v_mreceipt1 tables. I wonder why didn't you do this. Anyways let me know if any issues wt this SQL.
Aug 17 '09 #2
just add a break statement.

--
-- without a break statement
--
select owner
,table_name
from all_tables
where owner in ('SYS','SYSTEM')
order by owner
,table_name

OWNER TABLE_NAME
------------------------ -----------------------------
SYS AUDIT_ACTIONS
SYS AW$AWCREATE
SYS OLAP_OLEDB_MDPROPVALS
SYS PLAN_TABLE$
SYS PSTUBTBL
SYS WRI$_ADV_ASA_RECO_DATA
SYSTEM DEF$_TEMP$LOB
SYSTEM HELP
SYSTEM MVIEW$_ADV_PARTITION
SYSTEM OL$
SYSTEM OL$NODES

--
-- With a break statement
--
SQL> break on owner

SQL> l
1 select owner
2 ,table_name
3 from all_tables
4 where owner in ('SYS','SYSTEM')
5 order by owner
6* ,table_name


OWNER TABLE_NAME
------------------------ -----------------------------
SYS AUDIT_ACTIONS
AW$AWCREATE
OLAP_OLEDB_MDPROPVALS
PLAN_TABLE$
PSTUBTBL
WRI$_ADV_ASA_RECO_DATA
SYSTEM DEF$_TEMP$LOB
HELP
MVIEW$_ADV_PARTITION
OL$
OL$NODES

Hope this helps.
Aug 19 '09 #3
Sorry... trying to get the output to look proper on this site. Hopefully, this will show you what the ouput should look like when you use the break statement.

OWNER TABLE_NAME
------------------------ -----------------------------
SYS AUDIT_ACTIONS
AW$AWCREATE
OLAP_OLEDB_MDPROPVALS
PLAN_TABLE$
PSTUBTBL
WRI$_ADV_ASA_RECO_DATA
SYSTEM DEF$_TEMP$LOB
HELP
MVIEW$_ADV_PARTITION
OL$
OL$NODES
Aug 19 '09 #4
OraMaster
135 100+
Hi

Using break it's not giving desired output when I did try on Oracle 9i.
Aug 19 '09 #5
I've used "break on" since version 7. Are you using sqlplus or do you need to run this in a different query tool?
Aug 19 '09 #6
OraMaster
135 100+
@jsmithstl
Yes I did. It's working.
Aug 19 '09 #7
OraMaster
135 100+
@jsmithstl
But I guess it's SQL * Plus command and we can't use it in procedure or function etc.
Aug 20 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: mike | last post by:
Ok, I'll admit I'm VERY new to ASP but I simply cannot seem to get this to work. The problem is probably obvious but I just can't seem to find it. I'm trying to query an Oracle DB on another...
4
by: francis70 | last post by:
Hi, I have these 2 problem? Is there a way in Oracle to read UNCOMMITED data. i.e. in Oracle the normal behaviour is that a user's updates to a table are visible to other users ONLY when the...
1
by: Cern | last post by:
Is it somebody out there who has made a migration from an Oracle server to an MySQL server?? The scenario is as simply: I've got a Oracle 8 server with a database with content that I want to...
3
by: Jon Ole Hedne | last post by:
My Access 2002-application need to work with tables from both Oracle and Access. To solve this, I want to run some querys on three views in Oracle and import the results into temporary...
8
by: Alfonso Esteban Gonzalez Sencion | last post by:
I am trying to use Access as a front end for extracting information from an Oracle database. I started using linked tables but I am getting a very curious behaviour. When I consult the linked...
5
by: premmehrotra | last post by:
I am using Microsoft Access 2000 and Oracle 9.2.0.5 on Windows 2000. When I export a table from Access to Oracle using ODBC I get error: ORA 972 identifier too long I think the error is because...
14
by: peteh | last post by:
Hi All; We have many production jobs that "load from cursor" to a UDB/AIX 8.2 (with dpf) data warehouse from source tables residing Oracle 9i. Since Oracle dates are (roughly) equivalent to DB2...
11
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables,...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.