473,486 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A single query between two tables without link on its fields

mariusseven
19 New Member
SELECT
SUM (fieldname) AS T_Withheld
,SUM (fieldname) AS G_Income

,SUM(fieldname) + SUM (fieldname) + SUM(fieldname) + SUM(fieldname) AS Premium
,SUM (fieldname) - fieldnameC - (SUM(fieldname) + SUM (fieldname) + SUM(fieldname) + SUM(fieldname)) AS T_Income
,fieldnameA
,fieldnameB

FROM tablename A
GROUP
BY fieldnameA
,fieldnameB
,fieldnamec

and


select fieldnameA, fieldnameB, fieldnameC, fieldnameD

from tablename B

Really need ideas
Mar 28 '08 #1
13 2444
code green
1,726 Recognized Expert Top Contributor
By no link do you mean there is no common field between the two tables?
If that is the case what is wrong with two select statements?
Mar 28 '08 #2
poe
32 New Member
You don't have to have a link to join tables. There should be something similar between these two tables to join on, correct?

I think it would help if you gave full, correct SQL statement(s).
Mar 28 '08 #3
ck9663
2,878 Recognized Expert Specialist
How would you know which record pairs with what record?

-- CK
Mar 28 '08 #4
mariusseven
19 New Member
I want to make only one query because i'll be using it to create a .ttx file of crystal reports to be used in vb6.




By no link do you mean there is no common field between the two tables?
If that is the case what is wrong with two select statements?
Mar 29 '08 #5
mariusseven
19 New Member
The data i need are from two tables that have nothing in common..is it impossible to create a single query on both of their fields?


How would you know which record pairs with what record?

-- CK
Mar 29 '08 #6
ck9663
2,878 Recognized Expert Specialist
Not impossible.

Would you mind posting sample data on both tables an how you want it joined?

-- CK
Mar 29 '08 #7
mariusseven
19 New Member
Sorry for the late relpy..
here is the sample of tables....

table 1
Name......Cont1..... Cont2...... Cont3.....Cont4

Name1 .....100 ......200 .........300.........400
Name2......500...... 600..........700.........800
Name3 ......900......1000........1100 ......1200

table 2
Code ......%Cont ......ContA......ContIN ..... ContFL
Code1 ...... 0 .............. 0 ........ 0 ............ 100000
Code2. ...... 5 ........... 500.........10000........30000
Code3. .......10........ ..1000........30000 ....... 70000
Code4.........15...........1500........70000 ...... .14000
Apr 2 '08 #8
ck9663
2,878 Recognized Expert Specialist
How do you want this joined? How would the joined table look?

-- CK
Apr 2 '08 #9
mariusseven
19 New Member
i just want the query of both tables, i don't want them to join or merge. i want to query them using a single query with filters.
Its like i want to compare the total values of the first table cont to the range of the values of the second.


How do you want this joined? How would the joined table look?

-- CK
Apr 2 '08 #10
code green
1,726 Recognized Expert Top Contributor
just want the query of both tables, i don't want them to join or merge. i want to query them using a single query with filters
A JOIN doesn't merge tables,
it merges results from the tables in to one recordset.
The tables are unaffected.
You want to run a query collecting results from both tables which is normally a JOIN query,
but requires common data in at least one field of each table.
Without this you could try a UNION which is two SELECT statements with UNION between.
The number of fields in each SELECT must match
Apr 2 '08 #11
ck9663
2,878 Recognized Expert Specialist
I'll give him the benefit of the doubt ;)

Based on your example, how would you do it in a pseudo-code?

-- CK
Apr 2 '08 #12
mariusseven
19 New Member
The code i have made was the one that i have posted first, but i have no idea on how to connect the two...


I'll give him the benefit of the doubt ;)

Based on your example, how would you do it in a pseudo-code?

-- CK
Apr 8 '08 #13
code green
1,726 Recognized Expert Top Contributor
We seem to be going around in circles.
The code i have made was the one that i have posted first, but i have no idea on how to connect the two
By connect I have to assume you mean JOIN.
Unfortunately YOU need to tell us how you want the tables JOINed because we do not know what you are trying to achieve.
Its like i want to compare the total values of the first table cont to the range of the values of the second
How are you hoping to do this?
Apr 8 '08 #14

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

Similar topics

0
1833
by: Gianfranco | last post by:
Hi I got a problem with 2 tables. I have a table, say A, with x records, coming from a make table query and a table, say B, with y records, coming from another make table query. I need to join...
5
4453
by: deko | last post by:
How to run action query against linked table? I have an Access 2003 mdb with an Excel 2003 Workbook as a linked table. When I attempt to run an action query against the linked table I get this...
5
3305
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
1
1996
by: hmiller | last post by:
I'm sorry to populate the server with yet another question about linking multiple tables and queries, howerver I have not been able to find the right criteria. My problem. I am trying to...
10
1989
by: Nitin | last post by:
I have Oracle 9.2 tables linked in Access. Data can be pulled from all the tables except one !! It gives "ODBC connection failed" error when trying to open the link.I deleted the link and created...
0
3280
by: phlype.johnson | last post by:
I'm struggling to find the best query from performance point of view and readability for a normalized DB design. To illustrate better my question on whether normalized designs lead to more complex...
4
1359
by: steves | last post by:
Hello All, I am trying to link to an existing database and extend the funcitonality by adding a phone call logging extension, so you can see a list of phone calls for a given customer. There...
4
2028
by: Doris | last post by:
It does not look like my message is posting....if this is a 2nd or 3rd message, please forgive me as I really don't know how this site works. I want to apologize ahead of time for being a novice...
16
3460
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
9
3607
by: Sinner | last post by:
Hi, I have a field name 'USER' in tableMAIN. How do I replace the user names with corresponding user names. I can do that in xl using vlookup but now I'm trying to find a way to do that in...
0
6964
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
7175
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...
1
6842
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...
0
7330
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
5434
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,...
1
4865
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...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.