|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Double data trouble.
Here's a nice query I'm using to fetch data to access prices for items.
The trouble is that it fetches the correct data, twice! The problem is probably caused by the following; -DLG_ITEM.ITEMID is unique -KATSELU_REPRO_NEEDS_BUFFER is not unique, it can have many ITEMID's The nice query: SELECT KATSELU_REPRO_NEEDS_BUFFER.PROJID, KATSELU_REPRO_NEEDS_BUFFER.COMPANY, KATSELU_REPRO_NEEDS_BUFFER.WORK_NUMBER, KATSELU_REPRO_NEEDS_BUFFER.UNIT, KATSELU_REPRO_NEEDS_BUFFER.ITEMID, KATSELU_REPRO_NEEDS_BUFFER.ITEMNAME, (KATSELU_REPRO_NEEDS_BUFFER.ITEM_TYPE) AS Expr1, KATSELU_REPRO_NEEDS_BUFFER.NEED_TYPE, KATSELU_REPRO_NEEDS_BUFFER.NEED_STATUS, (KATSELU_REPRO_NEEDS_BUFFER.QTY) AS QTY, (KATSELU_DLG_ITEM.AVGPRICE) AS AVGPRICE FROM KATSELU_REPRO_NEEDS_BUFFER, KATSELU_DLG_ITEM WHERE (((KATSELU_REPRO_NEEDS_BUFFER.ITEMID)=[KATSELU_DLG_ITEM].[ITEMID]) AND ((KATSELU_REPRO_NEEDS_BUFFER.NEED_TYPE_NAME)='NIP -mat.varaus')); Here's how it works; -for every PROJECT, WORK_NUMBER, ITEMID -fetch QTY (quantity) from REPRO table -fetch AVGPRICE from DLG_ITEM table the result should be an amount of rows equal to the amount of rows in REPRO table, but somehow, the amount isn't that, it's double.. because the original REPRO table holds 6804 rows, while my result is 13582. Has anyone got any wise solutions? ![]() Hena |
|
#2
|
|||
|
|||
|
Oh, now I feel silly, have been tearing hairs for the last hours, but couldn't figure it out..
Then I just checked with a modified query why it would show double amounts, in the end, DLG_ITEM didn't have ITEMID as unique as I first mentioned, it's unique only per COMPANY, but I ofcourse had forgotten the universal company='our company' :P Problem solved anyhow ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Double data trouble. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|