473,396 Members | 1,921 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,396 software developers and data experts.

Oracle question.

Dear sir,

Iam Oracle developer(D2k), i have a problem in developing the query.....
let me explain in detail,

Report is Revenues for the year of Doctors.

i have develope the query, which give out but like:

Revenue type doctor name Amount
------------------------------------------------------------
consultation umesh k.m 5000

this for, total period.

but, i want to print, months wise,
like:
Revenue type doctor name jan feb mar april................. dec
--------------------------------------------------------------------------------------------------------

can u plz, help me out this problem.......

my query looks like:


Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. TO_CHAR(INVOICE_DATE,'MON') MONTH,
  3. TO_CHAR(INVOICE_DATE,'YYYY') YEAR, 
  4. REVENUE_TYPE_NAME, 
  5. DOCTOR_NAME, 
  6. SUM(AMOUNT) TOTALAMOUNT 
  7. FROM 
  8.        INVOICEMASTER IVM, 
  9.        INVOICEDETAILS IVD, 
  10.        DOCTORMASTER DTM, 
  11.        MASTERTABLE MRT, 
  12.        REVENUETYPEMASTER RTM, 
  13.        COSTCENTERMASTER CCM 
  14. WHERE 
  15.       IVM.INVOICE_NO=IVD.INVOICE_NO 
  16.       AND IVD.DOCTOR_CODE=DTM.DOCTOR_CODE 
  17.       AND IVD.SER_CODE=MRT.RECORD_CODE 
  18.       AND MRT.REVENUE_TYPE_CODE=RTM.REVENUE_TYPE_CODE 
  19.       AND MRT.COSTCENTER_CODE=CCM.COSTCENTER_CODE 
  20.           AND IVM. CANCELINVOICENO IS NULL 
  21.       AND IVD. AMOUNT > 0
  22. GROUP BY 
  23. TO_CHAR(INVOICE_DATE,'MON'),
  24. TO_CHAR(INVOICE_DATE,'YYYY'), 
  25. REVENUE_TYPE_NAME, 
  26. DOCTOR_NAME 
  27. ORDER BY 
  28. TO_CHAR(INVOICE_DATE,'MON'),
  29. TO_CHAR(INVOICE_DATE,'YYYY')
  30.  
plz help me out...

chandra....
Nov 15 '08 #1
13 1815
Stang02GT
1,208 Expert 1GB
This belongs in the Oracle forum and please make sure to use code tags when posting code. I will add them in for you this time.
Nov 16 '08 #2
Hello,

i have built a query, which gives amount of doctor monthly wise, I want to sum and place beside it.

query output as:

revenuetype doctor jan feb mar apr ...........dec
--------------------------------------------------------------------------------------------------------
consultation chandu 235 300 205 500 169.

but i want as follows

revenuetype doctor jan feb mar apr ...........dec Total
-----------------------------------------------------------------------------------------------------------------
consultation chandu 235 300 205 500 169. sum

by using this query, i want to develop a report in Reports6i.

plz, can anyone help out....

chandra......
Nov 16 '08 #3
Pilgrim333
127 100+
Hi,

What is the query you are using now?

Pilgrim.
Nov 16 '08 #4
amitpatel66
2,367 Expert 2GB
you just need to sum up all the columns that will give you total.

For Eg: (jan+feb+mar+apr+.....) Total
Nov 17 '08 #5
amitpatel66
2,367 Expert 2GB
What is the output of your query?...Could you please post the error your query is giving or in case incorrect ouput of your query?
Nov 17 '08 #6
hi amit,

thanks for ur, reply.....any how, i have resolved my problems by myself..
thank u for responding to my problems....

i have another problem,

Report format looks like:

Department:
Doctor name:
Revenue type:
Service Amount:
-----------------------------------

i have develop the query, but, i want to sum up each service and put the total in the amount column.

eg: per day if there are 5 new visits for a doctor, my query prints 5 times, but, i want to sum of this 5 new visits and print.
same as for Follow up.......etc...

my query:
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. CM.COSTCENTER_NAME,
  3. DM.DOCTOR_NAME,
  4. RM.REVENUE_TYPE_NAME,
  5. ID.INVOICE_NO,
  6. ID.ITEM_DRG_SER_NAME,
  7. ID.AMOUNT
  8. FROM 
  9. COSTCENTERMASTER CM,
  10. DOCTORMASTER DM,
  11. MASTERTABLE MT,
  12. REVENUETYPEMASTER RM,
  13. INVOICEDETAILS ID
  14. WHERE 
  15. REQ_DATE BETWEEN :FROMDATE AND :TODATE AND
  16. CM.COSTCENTER_CODE=DM.DEPT_CODE AND
  17. MT.REVENUE_TYPE_CODE=RM.REVENUE_TYPE_CODE AND
  18. MT.RECORD_CODE=ID.SER_CODE AND
  19. MT.COSTCENTER_CODE=CM.COSTCENTER_CODE
  20. GROUP BY 
  21. COSTCENTER_NAME,
  22. DOCTOR_NAME,
  23. RM.REVENUE_TYPE_NAME,
  24. ID.INVOICE_NO,
  25. ID.ITEM_DRG_SER_NAME,
  26. ID.AMOUNT
  27. ORDER BY 
  28. CM.COSTCENTER_NAME,
  29. DM.DOCTOR_NAME,
  30. RM.REVENUE_TYPE_NAME,
  31. ID.INVOICE_NO
can u help me out...
chandra
Nov 17 '08 #7
Pilgrim333
127 100+
Hi,

It would help if you would provide the solution that helped you with your first problem before posting another problem. The reason is, that other people who visit the forum can be helped by it.

Pilgrim.
Nov 17 '08 #8
amitpatel66
2,367 Expert 2GB
I did not understand your query that you have used. Why are you using a GROUP BY clause in your query?

Try the below query that would display list of visits and SUM(Amount) for visits on a particular day

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT  
  3. CM.COSTCENTER_NAME, 
  4. DM.DOCTOR_NAME, 
  5. RM.REVENUE_TYPE_NAME, 
  6. ID.INVOICE_NO, 
  7. ID.ITEM_DRG_SER_NAME, 
  8. SUM(ID.AMOUNT) OVER(PARTITION BY TRUNC(REQ_DATE) ORDER BY TRUNC(REQ_DATE)) Total_Amount 
  9. FROM  
  10. COSTCENTERMASTER CM, 
  11. DOCTORMASTER DM, 
  12. MASTERTABLE MT, 
  13. REVENUETYPEMASTER RM, 
  14. INVOICEDETAILS ID 
  15. WHERE  
  16. REQ_DATE BETWEEN :FROMDATE AND :TODATE AND 
  17. CM.COSTCENTER_CODE=DM.DEPT_CODE AND 
  18. MT.REVENUE_TYPE_CODE=RM.REVENUE_TYPE_CODE AND 
  19. MT.RECORD_CODE=ID.SER_CODE AND 
  20. MT.COSTCENTER_CODE=CM.COSTCENTER_CODE 
  21. ORDER BY  
  22. CM.COSTCENTER_NAME, 
  23. DM.DOCTOR_NAME, 
  24. RM.REVENUE_TYPE_NAME, 
  25. ID.INVOICE_NO 
  26.  
  27.  
Nov 17 '08 #9
HAI AMIT,

Thank u for your reply,
I have executed ur query, iam getting repetation of data.
let me explain clearly,

ITEM_DRG_SER_NAME is the service, eg: newvist , reviews, followup,...etc.
i want to sum all the newvisits, followup and reviews seperatly by docor wise.....

for ex:
doctorname services amount
----------------------------------------------------------------------
chandra newvisit 50kd
chandra followup 150kd
chandra reviews 10kd
amit followup 200kd
umesh reviews 110kd....


i want in this way....
iam groping to avoid repeation of data....

thanks,
amit......
Nov 17 '08 #10
amitpatel66
2,367 Expert 2GB
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT  DISTINCT
  3. CM.COSTCENTER_NAME, 
  4. DM.DOCTOR_NAME, 
  5. RM.REVENUE_TYPE_NAME, 
  6. ID.INVOICE_NO, 
  7. ID.ITEM_DRG_SER_NAME, 
  8. SUM(ID.AMOUNT) OVER(PARTITION BY DM.doctor_name,ID.item_drg_ser_name ORDER BY DM.doctor_name,ID.item_drg_ser_name) Total_Amount 
  9. FROM  
  10. COSTCENTERMASTER CM, 
  11. DOCTORMASTER DM, 
  12. MASTERTABLE MT, 
  13. REVENUETYPEMASTER RM, 
  14. INVOICEDETAILS ID 
  15. WHERE  
  16. REQ_DATE BETWEEN :FROMDATE AND :TODATE AND 
  17. CM.COSTCENTER_CODE=DM.DEPT_CODE AND 
  18. MT.REVENUE_TYPE_CODE=RM.REVENUE_TYPE_CODE AND 
  19. MT.RECORD_CODE=ID.SER_CODE AND 
  20. MT.COSTCENTER_CODE=CM.COSTCENTER_CODE
  21. ORDER BY  
  22. CM.COSTCENTER_NAME, 
  23. DM.DOCTOR_NAME, 
  24. RM.REVENUE_TYPE_NAME, 
  25. ID.INVOICE_NO 
  26.  
  27.  
Nov 17 '08 #11
Hai amit...

Thank a lot, u have done it......thank u so much........,
i too tried and got the result, but, i have used subquery and u dont it without subquer...
anyhow.....thanks...
for further support, i will get back to u...


chandra...
Nov 17 '08 #12
amitpatel66
2,367 Expert 2GB
Hey no problem. I am glad that I could help you. Yep do post back in case of any further issues.

Moderator
Nov 17 '08 #13
amitpatel66
2,367 Expert 2GB
Duplicate threads merged for better management of forum

MODERATOR
Nov 17 '08 #14

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

Similar topics

0
by: Mark Townsend | last post by:
Following is a summary of articles spanning a 7 day period, beginning at 23 Feb 2004 05:29:19 GMT and ending at 01 Mar 2004 04:12:14 GMT. Notes ===== - A line in the body of a post is...
1
by: Gilles Cadorel | last post by:
Sur un PC, nous avons installé plusieurs version d'Oracle Client. Plusieurs logiciels tiers utilisant Oracle ne demandent pas lors de leur installation, quelle version d'Oracle utiliser. Ces...
38
by: Mike | last post by:
No flame wars, please! We're planning a move from a non-relational system to a relational system. Our choices have been narrowed to Oracle and DB2. Since we're moving from non-relational to...
11
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
125
by: Rhino | last post by:
One of my friends, Scott, is a consultant who doesn't currently have newsgroup access so I am asking these questions for him. I'll be telling him how to monitor the answers via Google Newsgroup...
7
by: Murtix Van Basten | last post by:
Hi all, I will deploy a database project to an Oracle server, but I could not figure out which version of Oracle should I get. Here is my configuration: Hardware: Dell 1750 Dual Xeon 3.2Ghz,...
11
by: Mark A | last post by:
Here is Mark Townsend's (Oracle Product Manager) explanation and justification for posting in the DB2 newsgroup, as posted on the Oracle newsgroup, and my response: "Mark Townsend"...
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...
6
by: JV | last post by:
A ref cursor data type can obviously be returned as an output parameter of a stored procedure, but can an ASP.NET application call an oracle proc that uses a ref cursor as an input parameter? If...
14
by: jehugaleahsa | last post by:
Hello: I am working with Oracle .NET Stored Procedures. I would like to know how to return the results of a SELECT statement. I have tried returning a OracleRefCursor and a DataTable, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.