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

Same table query

2
Greetings All,

I am trying to do a week on week query. The basic idea is we see how much extra (or less) we have sold compared to last week.


Query:
SELECT TblSub.SubName, TblWeekly.LineId, TblLine.LineDesc, TblWeekly.Unit, TblWeekly_1.Unit AS Expr1, TblWeekly.Reg, TblWeekly_1.Reg AS Expr2,
TblWeekly.Was, TblWeekly_1.Was AS Expr3, TblWeekly.Red, TblWeekly_1.Red AS Expr4, TblWeekly.Con2, TblWeekly_1.Con2 AS Expr5
FROM TblWeekly TblWeekly_1 RIGHT OUTER JOIN
TblWeekly INNER JOIN
TblLine ON TblWeekly.LineId = TblLine.LineId INNER JOIN
TblCoy ON TblLine.LineCoy = TblCoy.ID INNER JOIN
TblCat ON TblLine.LineCat = TblCat.ID INNER JOIN
TblSub ON TblLine.LineSubGroup = TblSub.Id ON TblWeekly_1.LineId = TblWeekly.LineId AND TblWeekly_1.WEndID = TblWeekly.WEndID - 7
WHERE (TblCat.CatName = 'Company') AND (TblWeekly.WEndID = CONVERT(DATETIME, '13/01/2007', 103))
ORDER BY TblSub.SubName DESC, TblWeekly.LineId

The results are (trimmed)
TblLine.LineDesc, TblWeekly.Unit, TblWeekly_1.Unit
12345 100 90
54321 90 1000
98765 100 <null>
56789 <null> 1000 <-this line does not show in the query

Product 56789 does not show in the query because there are no sales for the previous week.

It must be a 'join' issue somewhere, but I can;t see it.

Many thanks for having a look
Jan 26 '07 #1
1 1057
mmouse
2
Sorted it out.
Jan 26 '07 #2

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

Similar topics

4
by: PC Datasheet | last post by:
How do you copy a table into the same database and give it a new name? For example, copy "MyTable" and give the copy the name "MyNewTable". Thanks, Steve
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
0
by: Bkster | last post by:
I have an access database where I have a main table built where records are being inserted from a web page. I have several fields that reference the same table. For example in this form you can...
1
by: keliie | last post by:
I have a relatively simple (I assume) issue which I am at a complete loss to address. My issues is: I want to populate fields in my tables with summary data from the same table. Let me explain: ...
1
by: fong.yang | last post by:
I've got a database with about 300,000 records. There are several different tables that are set up the same way with identical fields. I have the same queries individually set up for each table. ...
6
by: Steve | last post by:
I realize that this probably isn't a best practice, but I'm working with legacy code that has a query stored in one column of a table. Because the queries vary, the JSP page that selects a query...
17
by: vish | last post by:
Hi all, I know this might look strange at first look, but i am looping thru a dataset created using to different tables from database.These two tables have some fields with the same names. ...
3
by: eholz1 | last post by:
Hello PHP programmers. I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a...
3
by: Robertf987 | last post by:
Hi, I'm a bit stuck with an access database. I'm using access 2000 if that's any help. Right, it's 3:40am right now and I'm rather tired, but I *hope* this makes sense. I have a table which...
9
by: magickarle | last post by:
Hi, I have a database in access with the following columns: Day AgentID ManagerID Grade They got information about agents and some grades. I would like to have ONE form with several...
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?
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
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.