Home » SQL & PL/SQL » SQL & PL/SQL » problem with query (oracle 9i,win xp)
problem with query [message #330739] Tue, 01 July 2008 01:35 Go to next message
sharathmpatil
Messages: 38
Registered: February 2008
Location: Bangalore
Member

HI
Please find the query attached with this post.The query is a part of report .When i run the query it repeats 25 times for the same customer n same item.Please suggest a solution.

Regards.
Re: problem with query [message #330740 is a reply to message #330739] Tue, 01 July 2008 01:41 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Laughing

If the query is small post it in the topic don't attach a file.
But before (and this is also true for attached file), please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.

Regards
Michel
Re: problem with query [message #330751 is a reply to message #330739] Tue, 01 July 2008 02:14 Go to previous messageGo to next message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
SELECT <column list>
FROM po,po2,po3,imas,uom,party,dcode mcat,dcode, plan
WHERE <join conditions>
GROUP BY <column list>

> When i run the query it repeats 25 times for the same customer n same item.
Can you tell how is anybody supposed to deduce which are "customer" and "item" tables.

> Please suggest a solution.
Appropriately join the tables. In the attached query, there is not join condition for the PLAN table.
You may need to use more conditions for other tables too.
Also it may be the normal behavior as "the same customer n same item" may be joined to more rows in other tables.
Re: problem with query [message #330774 is a reply to message #330751] Tue, 01 July 2008 03:31 Go to previous message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
it repeats 25 times for the same customer n same item.

Well, perhaps there really are 25 records for this "customer + item" combination (which means that query works fine).

Otherwise, join is probably wrong (or incomplete) and WHERE clause requires additional conditions.

Also, although it doesn't mean that you've reached the solution, SELECT DISTINCT might reduce number of rows returned by this query.
Previous Topic: Joining two queries in one query
Next Topic: how to Find hardisk ID
Goto Forum:
  


Current Time: Sat Dec 03 07:59:34 CST 2016

Total time taken to generate the page: 0.11585 seconds