473,406 Members | 2,816 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.

Full Joins And Null Fields

OK Ill explain this as best as I can

I have two tables - I buy widgets in the hundreds but they are different sorts. I sell widgets of the same kind in different numbers and kinds.

I want a purchases and sales report all in one

i.e

Expand|Select|Wrap|Line Numbers
  1. purchaseName  PurchaseNo  PurchasePrice  SaleName  SaleNo  SalePrice
  2. Widget1           100          100       Widget1     100      200
  3. Widget2           100          200       Widget2      50      150
  4.                                          Widget2      25      150
  5. Widget3           100          300
  6. Widget4           200          400       Widget4      50      100
You can see from the above how I want to format my report, i have managed to display all the data as above - the only issue being that if I sell part of the item multiple times it duplicates the purchase column - I really need the purcahse colums to be blank, here is what I have - i do hope someone can help
Expand|Select|Wrap|Line Numbers
  1. SELECT purchase.purchaseitem, purchase.purchaseprice, purchase.purchasenumber, sales.saleitem, sales.saleprice, sales.salenumber
  2. FROM purchase INNER JOIN sales ON purchase.purchaseitem=sales.saleitem;
  3. UNION ALL
  4. SELECT purchase.purchaseitem, purchase.purchaseprice, purchase.purchasenumber, sales.saleitem, sales.saleprice, sales.salenumber
  5. FROM purchase LEFT JOIN sales ON purchase.purchaseitem=sales.saleitem
  6. WHERE (((sales.saleitem) Is Null));
  7. UNION ALL 
  8. SELECT purchase.purchaseitem, purchase.purchaseprice, purchase.purchasenumber, sales.saleitem, sales.saleprice, sales.salenumber
  9. FROM purchase RIGHT JOIN sales ON purchase.purchaseitem = sales.saleitem
  10. WHERE (((purchase.purchaseitem) Is Null));
Jul 5 '08 #1
4 1371
Hey,

Better u create the report, with the groping.
ie, create group on PurchaseItem. In this header u set the lable and text control of the purchase item. And other controls labels only u set here and also u keep the other text controls in detail section.

Sorry for the confusion.
Jul 5 '08 #2
Stewart Ross
2,545 Expert Mod 2GB
Hi. As Salimudheen says, you can use the grouping facilities on a report to group by the purchase details. If you do so you can either have a staggered layout for the report data by placing the purchase fields in the header of the group then using the detail section to show the sales fields, or do as you show in post 1 and list all fields in the detail section.

If you put all fields in the detail section you could use the Hide Duplicates property of the textboxes on the report to list only the first occurrence of each, but doing so sometimes does not achieve an effect that looks as good to the user if there are several textboxes involved. It is worth experimenting to find out.

-Stewart
Jul 5 '08 #3
NeoPa
32,556 Expert Mod 16PB
I would say this request is too non-specific to have an answer.

Your implementation of an OUTER JOIN is innovative, though this could possibly have been more easily done with no JOIN but with a WHERE clause specifying only matching records be included.

Without a specified unique reference though there are many potential problems. You could avoid duplicates, but how could you tell if they were referring to the same actual item or not?
Jul 8 '08 #4
NeoPa
32,556 Expert Mod 16PB
To drop duplicates, there is a DISTINCT (or DISTINCTROW) predicate for the SELECT clause. This maps to the UniqueValues and UniqueRecords properties in the QueryDef.

Again, be careful of this as it may be possible to lose duplicates that you really need to keep.
Jul 8 '08 #5

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

Similar topics

3
by: Prem | last post by:
Hi, I am having many problems with inner join. my first problem is : 1) I want to know the precedance while evaluating query with multiple joins. eg. select Employees.FirstName,...
3
by: brendan_gallagher_2001 | last post by:
Hi, I have a view(A) and I am trying to do a join on another table (B) to include only rows where date values in view A is greater than in table B. I also want the view to pick up rows in viewA...
4
by: Scott Marquardt | last post by:
My SQL acumen stems from just a couple courses, and everything since from the trenches. Fun + angst over time. I'm needing some advice on joins. Though I understand the basics, I'm having...
4
by: Anthony Robinson | last post by:
I was actually just wondering if someone could possibly take a look and tell me what I may be doing wrong in this query? I keep getting ambiguous column errors and have no idea why...? Thanks in...
0
by: Hegedus, Tamas . | last post by:
Dear All, I am a biologist and I do not know what to expect from an RDB (PgSQL). I have large tables: 1215607 rows in prots, 2184596 rows in kwx (see table details below). I would like to do...
11
by: frizzle | last post by:
Hi groupies I'm building a news site, to wich a user can add new items into a mySQL db. It's still in testfase, but it's so extremely slow, i want to figure out what i'm doing wrong, or what to...
2
by: beargrease | last post by:
I'm kind of comfortable with basic joins, but a current project requires a complex query of many tables. The GROUP_CONCAT(DISTINCT ...) function has been very useful as returning my values as comma...
1
by: charliej | last post by:
I have two tables, one has two phone fields and the other has four phone fields. Everything is standardized to 10 digits per field and I import them as text. Is it possible to join them based on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.