473,395 Members | 2,468 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,395 software developers and data experts.

Mismatch Records field need display Null

112 100+
I have 3 table for Purchase Order from ERP Database
Tables:
POD=Purchase order Details(this table has Require Qty field)
POR=Purchase Order Receive (This table has RequireQty and ReceiptQty Fields)
POI=Purchase order Inspect

I want a query to display Purchase order History. My Query is here

Expand|Select|Wrap|Line Numbers
  1. SELECT dbo.POD.POD_PurchOrderID, dbo.POD.POD_POLineNbr, dbo.POI.POI_StatusCode, 
  2.       dbo.ProjectGroup.PRJG_ProjectID, dbo.POI.POI_Reference, dbo.POI.POI_ItemName, 
  3.       dbo.POI.POI_UnitMeasure, dbo.POD.POD_RequiredDate, dbo.POD.POD_PromiseDate, 
  4.       dbo.POR.POR_ReceiverDate, dbo.POD.POD_RequiredQty, dbo.POR.POR_ReceiptQty, dbo.POD.POD_POUnitPrice, 
  5.       dbo.POD.POD_POUnitPrice * dbo.POR.POR_ReceiptQty AS Amt
  6. FROM dbo.POD INNER JOIN
  7.       dbo.POR ON dbo.POD.POD_RequiredDate = dbo.POR.POR_RequiredDate AND 
  8.       dbo.POD.POD_PurchOrderID = dbo.POR.POR_PurchOrderID INNER JOIN
  9.       dbo.POI ON dbo.POD.POD_POLineNbr = dbo.POI.POI_POLineNbr AND 
  10.       dbo.POR.POR_POLineNbr = dbo.POI.POI_POLineNbr AND 
  11.       dbo.POD.POD_PurchOrderID = dbo.POI.POI_PurchOrderID INNER JOIN
  12.       dbo.ProjectGroup ON 
  13.       dbo.POD.POD_PRJG_RecordID = dbo.ProjectGroup.PRJG_RecordID
This query only displaying the records which i have received and inspect. But still i have some records thats not received and inspect.

I want to display all the records which is received and not recieved
If not received receipt qty field should be null.

ERP generate records according porecipt. If not receipt then no records in POR table

Thnx
Apr 22 '08 #1
7 1793
ck9663
2,878 Expert 2GB
It's because you're using INNER JOIN.

Try using LEFT or RIGHT JOIN.

-- CK
Apr 22 '08 #2
imtmub
112 100+
It's because you're using INNER JOIN.

Try using LEFT or RIGHT JOIN.

-- CK
If i use right join i m getting the same result. but left join producing duplicate records.

Example result:
Now i m getting the report like this(This is Example displaying only few fields)

PurchOrderID,POLineNbr,ProjectID,....,RequiredQty, ReceiptQty ,.........
PO12345, 1, S01243, ....,45.00, 25.00, ..........
PO12345, 1, S01234, .....,10.00, 10.00,...........
PO12345, 2, S01234, .....,25.00, 25.00 ..........

But i want the result like This

PurchOrderID,POLineNbr,ProjectID,....,RequiredQty, ReceiptQty ,.........
PO12345, 1, S01243, ....,45.00, 25.00, ..........
PO12345, 1, S01234, .....,10.00, 10.00,...........
PO12345, 2, S01234, .....,25.00, 25.00 ..........
PO12345, 3, S01233, ......,15.00, 0.00, ...........



In this above example the POLineNbr 3 (result row 4) still not yet received. So i dont records exist POR Table. But i want to display those records in my report.

Please give me the query or example site to get this

Thanks
Apr 22 '08 #3
SELECT dbo.POD.POD_PurchOrderID, dbo.POD.POD_POLineNbr, dbo.POI.POI_StatusCode,

dbo.ProjectGroup.PRJG_ProjectID, dbo.POI.POI_Reference, dbo.POI.POI_ItemName,

dbo.POI.POI_UnitMeasure, dbo.POD.POD_RequiredDate, dbo.POD.POD_PromiseDate,

dbo.POR.POR_ReceiverDate, dbo.POD.POD_RequiredQty, dbo.POR.POR_ReceiptQty, dbo.POD.POD_POUnitPrice,

dbo.POD.POD_POUnitPrice * dbo.POR.POR_ReceiptQty AS Amt

FROM dbo.POD
--- In SQL the Table follow FROM clause is considered as LEFT Table
-- The Table which follow the JOIN stmt are considered as RIGHT Table
INNER JOIN

dbo.POR ON dbo.POD.POD_RequiredDate = dbo.POR.POR_RequiredDate AND

dbo.POD.POD_PurchOrderID = dbo.POR.POR_PurchOrderID INNER JOIN

dbo.POI ON dbo.POD.POD_POLineNbr = dbo.POI.POI_POLineNbr AND

dbo.POR.POR_POLineNbr = dbo.POI.POI_POLineNbr AND

dbo.POD.POD_PurchOrderID = dbo.POI.POI_PurchOrderID INNER JOIN

dbo.ProjectGroup ON

dbo.POD.POD_PRJG_RecordID = dbo.ProjectGroup.PRJG_RecordID

-------------------------------------------------------------------------------------------------------
In SQL the Table follow FROM clause is considered as LEFT Table
The Table which follow the JOIN stmt are considered as RIGHT Table

Based on the above information u can try...

Ganesh
Apr 23 '08 #4
imtmub
112 100+
SELECT dbo.POD.POD_PurchOrderID, dbo.POD.POD_POLineNbr, dbo.POI.POI_StatusCode,

dbo.ProjectGroup.PRJG_ProjectID, dbo.POI.POI_Reference, dbo.POI.POI_ItemName,

dbo.POI.POI_UnitMeasure, dbo.POD.POD_RequiredDate, dbo.POD.POD_PromiseDate,

dbo.POR.POR_ReceiverDate, dbo.POD.POD_RequiredQty, dbo.POR.POR_ReceiptQty, dbo.POD.POD_POUnitPrice,

dbo.POD.POD_POUnitPrice * dbo.POR.POR_ReceiptQty AS Amt

FROM dbo.POD
--- In SQL the Table follow FROM clause is considered as LEFT Table
-- The Table which follow the JOIN stmt are considered as RIGHT Table
INNER JOIN

dbo.POR ON dbo.POD.POD_RequiredDate = dbo.POR.POR_RequiredDate AND

dbo.POD.POD_PurchOrderID = dbo.POR.POR_PurchOrderID INNER JOIN

dbo.POI ON dbo.POD.POD_POLineNbr = dbo.POI.POI_POLineNbr AND

dbo.POR.POR_POLineNbr = dbo.POI.POI_POLineNbr AND

dbo.POD.POD_PurchOrderID = dbo.POI.POI_PurchOrderID INNER JOIN

dbo.ProjectGroup ON

dbo.POD.POD_PRJG_RecordID = dbo.ProjectGroup.PRJG_RecordID

-------------------------------------------------------------------------------------------------------
In SQL the Table follow FROM clause is considered as LEFT Table
The Table which follow the JOIN stmt are considered as RIGHT Table

Based on the above information u can try...

Ganesh
Hi Ganesh,
Sorry it has taken me a while to get back to you, but thanks very much for your sql

Imthi
May 12 '08 #5
imtmub
112 100+
But Still i didnt get what i want. I have three table (POD-PoDetails, POR-PoRecieve & POI-PoInspect)
POD is base table for the rest. In the POR & POI the records only generated if the Item received/Inspect Respectively. Also both POR&POI operation not done in same time some times they will take upto one week. Untill then the record not exist in the respective table.

My query fields link with all this 3 tables if the record is not exist even in one table the records it wont display. Its basic i know.

But i need the recorsd to display. if the field is not exist then it should show NULL value.

Thanks
May 12 '08 #6
Delerna
1,134 Expert 1GB
Try this
Expand|Select|Wrap|Line Numbers
  1. SELECT     POD.POD_PurchOrderID, 
  2.     POD.POD_POLineNbr, 
  3.     POI.POI_StatusCode, 
  4.           ProjectGroup.PRJG_ProjectID, 
  5.     POI.POI_Reference, 
  6.     POI.POI_ItemName, 
  7.     POI.POI_UnitMeasure, 
  8.     POD.POD_RequiredDate, 
  9.     POD.POD_PromiseDate, 
  10.     POR.POR_ReceiverDate, 
  11.     POD.POD_RequiredQty, 
  12.     POR.POR_ReceiptQty, 
  13.     POD.POD_POUnitPrice, 
  14.     POD.POD_POUnitPrice * dbo.POR.POR_ReceiptQty AS Amt
  15. FROM dbo.POD 
  16. LEFT JOIN POR ON POD.POD_PurchOrderID = POR.POR_PurchOrderID 
  17. LEFT JOIN POI ON POD.POD_PurchOrderID = POI.POI_PurchOrderID 
  18.              AND POR.POR_POLineNbr = POI.POI_POLineNbr 
  19. LEFT JOIN ProjectGroup ON POD.POD_PRJG_RecordID = ProjectGroup.PRJG_RecordID
  20.  

If that dosn't work then post all the field names in all of the involved tables and maybe some demo data along with it and I will give you one that does.
It is not absolutely clear on what the necessary fields to join to are because you only list a few, and some of the crucial ones are missing.

I don't know why you joined to the RequiredDate so I removed it. I felt it might be unnecessary.
Anyway, hopefully the above will work for you. If not post what I requested
May 12 '08 #7
imtmub
112 100+
Thnx for ur support. Its Ok now
May 19 '08 #8

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

Similar topics

7
by: Jack | last post by:
Hi, I have posted this problem before. Apprently, the suggestion took care of the problem. However, still I am getting the above error message. I am using a session variable to transfer a value...
7
by: middletree | last post by:
I've been messing with this for hours, and have been to various sites, including Aaron's site, and am truly stumped. The short version: in SQL Server, the 4 fields in question are datetime. I...
3
by: Laurel | last post by:
this is driving me crazy. i need to use a form control as a criteria in a select query, and the control's value is set depending upon what a user selects in an option group on the form. the query...
3
by: Peter Phelps | last post by:
My problem is as follows: I need automatically iterate through a single field in a table and use the values in the field to create an in-statement. Currently, the character limitation in the...
3
by: Martin Lacoste | last post by:
Is there some issue with using too many left/right/mid/len functions in queries? Depending on the usage, they work fine, but... then there's here: SELECT Master_CAO.Incipit,...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
7
by: Mike | last post by:
Type Mismatch error I recieve a type mismatch error on the following line of code which is based on a specific date. It does NOT break on all records only "some". The dates for the records...
19
by: zz12 | last post by:
Hello, is there a setting in IIS 5.0 that would quickly fix the following error?: Microsoft VBScript runtime (0x800A000D) Type mismatch It's strange because some of our .asp pages were...
9
by: rscheinberg | last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.