PC Review


Reply
Thread Tools Rate Thread

Creating query from other queries- dates column

 
 
=?Utf-8?B?a2lt?=
Guest
Posts: n/a
 
      19th Jul 2007
I'm trying to create a query from other queries, all of which have a 'date'
column. However not all the queries have the same dates in e.g one query may
only have entries for 01/01/2006 and then for 05/01/2006 but not for any
dates inbetween these dates, although other queries may have. But the new
query seems to ignore the fact that other queries have data for these dates
inbetween and only display data for the dates that appear in the first query.
I want ALL dates that have data entries to appear, even if some columns will
have no entries (as some queries have no data for that date)- how do i stop
this? Please help- deeply distressed!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?c2N1YmFkaXZlcg==?=
Guest
Posts: n/a
 
      19th Jul 2007
Two immediate questions:

1) Are you creating a union query
2) What is the table design?





"kim" wrote:

> I'm trying to create a query from other queries, all of which have a 'date'
> column. However not all the queries have the same dates in e.g one query may
> only have entries for 01/01/2006 and then for 05/01/2006 but not for any
> dates inbetween these dates, although other queries may have. But the new
> query seems to ignore the fact that other queries have data for these dates
> inbetween and only display data for the dates that appear in the first query.
> I want ALL dates that have data entries to appear, even if some columns will
> have no entries (as some queries have no data for that date)- how do i stop
> this? Please help- deeply distressed!

 
Reply With Quote
 
=?Utf-8?B?a2lt?=
Guest
Posts: n/a
 
      19th Jul 2007
Firstly I'm not sure what a union query is- i am creating this 'linking'
query to link 2 previous queries in order to create a report from the final
query. In query 1 there are 4 fields i want to add- one of them being the
'date' field'. From the second query there is one field I want to add. For
some dates, the field from the second query dosn't contain any data- although
i still want this date to appear in the query- apologies if this doesn't make
sense. Do you understand what i mean?

"scubadiver" wrote:

> Two immediate questions:
>
> 1) Are you creating a union query
> 2) What is the table design?
>
>
>
>
>
> "kim" wrote:
>
> > I'm trying to create a query from other queries, all of which have a 'date'
> > column. However not all the queries have the same dates in e.g one query may
> > only have entries for 01/01/2006 and then for 05/01/2006 but not for any
> > dates inbetween these dates, although other queries may have. But the new
> > query seems to ignore the fact that other queries have data for these dates
> > inbetween and only display data for the dates that appear in the first query.
> > I want ALL dates that have data entries to appear, even if some columns will
> > have no entries (as some queries have no data for that date)- how do i stop
> > this? Please help- deeply distressed!

 
Reply With Quote
 
BruceM
Guest
Posts: n/a
 
      19th Jul 2007
It is difficult to understand what you are trying to do. What is the
real-world situation behind your efforts? Are both queries based on the
same table? You can add several tables to a query, but they won't work
together unless there is some sort of relationship between them (or if you
create a union query, as scubadiver asked about). However, since for a
union query you need to write SQL directly (rather than creating it through
design view), you would probably know if you had created one.
If the queries are both from the same table, you may need to change the join
type to get the results you want. In query design view, click the line that
links the two queries, then click View > Join Properties. The descriptions
for the join types may guide you in the right direction.

"kim" <(E-Mail Removed)> wrote in message
news29CDAF7-7765-43E4-A207-(E-Mail Removed)...
> Firstly I'm not sure what a union query is- i am creating this 'linking'
> query to link 2 previous queries in order to create a report from the
> final
> query. In query 1 there are 4 fields i want to add- one of them being the
> 'date' field'. From the second query there is one field I want to add.
> For
> some dates, the field from the second query dosn't contain any data-
> although
> i still want this date to appear in the query- apologies if this doesn't
> make
> sense. Do you understand what i mean?
>
> "scubadiver" wrote:
>
>> Two immediate questions:
>>
>> 1) Are you creating a union query
>> 2) What is the table design?
>>
>>
>>
>>
>>
>> "kim" wrote:
>>
>> > I'm trying to create a query from other queries, all of which have a
>> > 'date'
>> > column. However not all the queries have the same dates in e.g one
>> > query may
>> > only have entries for 01/01/2006 and then for 05/01/2006 but not for
>> > any
>> > dates inbetween these dates, although other queries may have. But the
>> > new
>> > query seems to ignore the fact that other queries have data for these
>> > dates
>> > inbetween and only display data for the dates that appear in the first
>> > query.
>> > I want ALL dates that have data entries to appear, even if some
>> > columns will
>> > have no entries (as some queries have no data for that date)- how do i
>> > stop
>> > this? Please help- deeply distressed!



 
Reply With Quote
 
=?Utf-8?B?c2N1YmFkaXZlcg==?=
Guest
Posts: n/a
 
      19th Jul 2007

I think I get what you mean. When you create the query do you show your two
queries and then drag a field from one query to the other to create a line?

The problem with doing this is that only records with information in each
query will be shown especially if the link you are using is the date! Ah ha?
So only those rows with a common date will show. That is why rows with no
dates are not showing.

FYI:

A union query joins queries together with common fields so you have rows
from all queries in one list. That may solve it for you. The idea for the SQL
is the following.

SELECT [field1], [field2]
From query1

UNION SELECT [field1], [field2]
From query2;

What you need to do is open a blank query. Close the "show table" box, go to
the top left hand corner and select "SQL". Then you will get a white screen
in which to paste the code.

Let me know...


"kim" wrote:

> Firstly I'm not sure what a union query is- i am creating this 'linking'
> query to link 2 previous queries in order to create a report from the final
> query. In query 1 there are 4 fields i want to add- one of them being the
> 'date' field'. From the second query there is one field I want to add. For
> some dates, the field from the second query dosn't contain any data- although
> i still want this date to appear in the query- apologies if this doesn't make
> sense. Do you understand what i mean?
>
> "scubadiver" wrote:
>
> > Two immediate questions:
> >
> > 1) Are you creating a union query
> > 2) What is the table design?
> >
> >
> >
> >
> >
> > "kim" wrote:
> >
> > > I'm trying to create a query from other queries, all of which have a 'date'
> > > column. However not all the queries have the same dates in e.g one query may
> > > only have entries for 01/01/2006 and then for 05/01/2006 but not for any
> > > dates inbetween these dates, although other queries may have. But the new
> > > query seems to ignore the fact that other queries have data for these dates
> > > inbetween and only display data for the dates that appear in the first query.
> > > I want ALL dates that have data entries to appear, even if some columns will
> > > have no entries (as some queries have no data for that date)- how do i stop
> > > this? Please help- deeply distressed!

 
Reply With Quote
 
=?Utf-8?B?a2lt?=
Guest
Posts: n/a
 
      19th Jul 2007
Ok- I've followed those instructions and when I go to open the new query I
get the message 'syntax error in from clause' - this is is exactly what I
typed in:

SELECT [Date], [Total Income]
From Income Daily Totals 2007 Query

UNION SELECT [Date], [Expr1]
From Figures 2007;

- do you have any idea where I could be going wrong? thanks so much for
your help so far!

"scubadiver" wrote:

>
> I think I get what you mean. When you create the query do you show your two
> queries and then drag a field from one query to the other to create a line?
>
> The problem with doing this is that only records with information in each
> query will be shown especially if the link you are using is the date! Ah ha?
> So only those rows with a common date will show. That is why rows with no
> dates are not showing.
>
> FYI:
>
> A union query joins queries together with common fields so you have rows
> from all queries in one list. That may solve it for you. The idea for the SQL
> is the following.
>
> SELECT [field1], [field2]
> From query1
>
> UNION SELECT [field1], [field2]
> From query2;
>
> What you need to do is open a blank query. Close the "show table" box, go to
> the top left hand corner and select "SQL". Then you will get a white screen
> in which to paste the code.
>
> Let me know...
>
>
> "kim" wrote:
>
> > Firstly I'm not sure what a union query is- i am creating this 'linking'
> > query to link 2 previous queries in order to create a report from the final
> > query. In query 1 there are 4 fields i want to add- one of them being the
> > 'date' field'. From the second query there is one field I want to add. For
> > some dates, the field from the second query dosn't contain any data- although
> > i still want this date to appear in the query- apologies if this doesn't make
> > sense. Do you understand what i mean?
> >
> > "scubadiver" wrote:
> >
> > > Two immediate questions:
> > >
> > > 1) Are you creating a union query
> > > 2) What is the table design?
> > >
> > >
> > >
> > >
> > >
> > > "kim" wrote:
> > >
> > > > I'm trying to create a query from other queries, all of which have a 'date'
> > > > column. However not all the queries have the same dates in e.g one query may
> > > > only have entries for 01/01/2006 and then for 05/01/2006 but not for any
> > > > dates inbetween these dates, although other queries may have. But the new
> > > > query seems to ignore the fact that other queries have data for these dates
> > > > inbetween and only display data for the dates that appear in the first query.
> > > > I want ALL dates that have data entries to appear, even if some columns will
> > > > have no entries (as some queries have no data for that date)- how do i stop
> > > > this? Please help- deeply distressed!

 
Reply With Quote
 
=?Utf-8?B?a2lt?=
Guest
Posts: n/a
 
      19th Jul 2007
....also, is it possible to create a union query based on another union query?
thanks again

"scubadiver" wrote:

>
> I think I get what you mean. When you create the query do you show your two
> queries and then drag a field from one query to the other to create a line?
>
> The problem with doing this is that only records with information in each
> query will be shown especially if the link you are using is the date! Ah ha?
> So only those rows with a common date will show. That is why rows with no
> dates are not showing.
>
> FYI:
>
> A union query joins queries together with common fields so you have rows
> from all queries in one list. That may solve it for you. The idea for the SQL
> is the following.
>
> SELECT [field1], [field2]
> From query1
>
> UNION SELECT [field1], [field2]
> From query2;
>
> What you need to do is open a blank query. Close the "show table" box, go to
> the top left hand corner and select "SQL". Then you will get a white screen
> in which to paste the code.
>
> Let me know...
>
>
> "kim" wrote:
>
> > Firstly I'm not sure what a union query is- i am creating this 'linking'
> > query to link 2 previous queries in order to create a report from the final
> > query. In query 1 there are 4 fields i want to add- one of them being the
> > 'date' field'. From the second query there is one field I want to add. For
> > some dates, the field from the second query dosn't contain any data- although
> > i still want this date to appear in the query- apologies if this doesn't make
> > sense. Do you understand what i mean?
> >
> > "scubadiver" wrote:
> >
> > > Two immediate questions:
> > >
> > > 1) Are you creating a union query
> > > 2) What is the table design?
> > >
> > >
> > >
> > >
> > >
> > > "kim" wrote:
> > >
> > > > I'm trying to create a query from other queries, all of which have a 'date'
> > > > column. However not all the queries have the same dates in e.g one query may
> > > > only have entries for 01/01/2006 and then for 05/01/2006 but not for any
> > > > dates inbetween these dates, although other queries may have. But the new
> > > > query seems to ignore the fact that other queries have data for these dates
> > > > inbetween and only display data for the dates that appear in the first query.
> > > > I want ALL dates that have data entries to appear, even if some columns will
> > > > have no entries (as some queries have no data for that date)- how do i stop
> > > > this? Please help- deeply distressed!

 
Reply With Quote
 
=?Utf-8?B?c2N1YmFkaXZlcg==?=
Guest
Posts: n/a
 
      19th Jul 2007

Add square brackets round the query names.

SELECT [Date], [Total Income]
From [Income Daily Totals 2007 Query]

UNION SELECT [Date], [Expr1]
From [Figures 2007];

I assume you can create union queries from other union queries but I don't
see why!




"kim" wrote:

> ...also, is it possible to create a union query based on another union query?
> thanks again
>
> "scubadiver" wrote:
>
> >
> > I think I get what you mean. When you create the query do you show your two
> > queries and then drag a field from one query to the other to create a line?
> >
> > The problem with doing this is that only records with information in each
> > query will be shown especially if the link you are using is the date! Ah ha?
> > So only those rows with a common date will show. That is why rows with no
> > dates are not showing.
> >
> > FYI:
> >
> > A union query joins queries together with common fields so you have rows
> > from all queries in one list. That may solve it for you. The idea for the SQL
> > is the following.
> >
> > SELECT [field1], [field2]
> > From query1
> >
> > UNION SELECT [field1], [field2]
> > From query2;
> >
> > What you need to do is open a blank query. Close the "show table" box, go to
> > the top left hand corner and select "SQL". Then you will get a white screen
> > in which to paste the code.
> >
> > Let me know...
> >
> >
> > "kim" wrote:
> >
> > > Firstly I'm not sure what a union query is- i am creating this 'linking'
> > > query to link 2 previous queries in order to create a report from the final
> > > query. In query 1 there are 4 fields i want to add- one of them being the
> > > 'date' field'. From the second query there is one field I want to add. For
> > > some dates, the field from the second query dosn't contain any data- although
> > > i still want this date to appear in the query- apologies if this doesn't make
> > > sense. Do you understand what i mean?
> > >
> > > "scubadiver" wrote:
> > >
> > > > Two immediate questions:
> > > >
> > > > 1) Are you creating a union query
> > > > 2) What is the table design?
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > "kim" wrote:
> > > >
> > > > > I'm trying to create a query from other queries, all of which have a 'date'
> > > > > column. However not all the queries have the same dates in e.g one query may
> > > > > only have entries for 01/01/2006 and then for 05/01/2006 but not for any
> > > > > dates inbetween these dates, although other queries may have. But the new
> > > > > query seems to ignore the fact that other queries have data for these dates
> > > > > inbetween and only display data for the dates that appear in the first query.
> > > > > I want ALL dates that have data entries to appear, even if some columns will
> > > > > have no entries (as some queries have no data for that date)- how do i stop
> > > > > this? Please help- deeply distressed!

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      19th Jul 2007
On Thu, 19 Jul 2007 07:38:02 -0700, kim <(E-Mail Removed)> wrote:

>Ok- I've followed those instructions and when I go to open the new query I
>get the message 'syntax error in from clause' - this is is exactly what I
>typed in:
>
>SELECT [Date], [Total Income]
>From Income Daily Totals 2007 Query
>
>UNION SELECT [Date], [Expr1]
>From Figures 2007;
>
> - do you have any idea where I could be going wrong? thanks so much for
>your help so far!


Blanks are meaningful delimiters. Access sees "Income" and "Daily" and
"Totals" and "2007" and "Query" as separate things, and doesn't know what to
do with all of them!

If you have something - table, field, query - with blanks or special
characters in its name, you must enclose that name in square brackets so
Access knows to treat it as a unit:

SELECT [Date], [Total Income]
From [Income Daily Totals 2007 Query]

UNION SELECT [Date], [Expr1]
From [Figures 2007];

Also, if you want the result sorted, you can include an ORDER BY clause in the
last SELECT clause:

UNION SELECT [Date], [Expr1]
From [Figures 2007]
ORDER BY [Date];

Note that Date is a reserved word (for the Date() function which returns
today's date from your computer clock) and that it's best not to use it as a
fieldname.

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help creating query involving dates HWhite Microsoft Access Queries 3 23rd Sep 2008 01:29 AM
Creating Static Column Headings in Crosstab Queries =?Utf-8?B?VHJpY2lhIFlvdW5n?= Microsoft Access Queries 5 29th Mar 2007 09:27 PM
Re: Creating a Query out of two queries Sean Massey Microsoft Access Queries 5 13th Dec 2006 10:59 PM
MS Query drops column aliases on certain queries Steff Microsoft Excel Programming 0 6th Sep 2006 11:00 AM
creating a query from two other queries =?Utf-8?B?dmVyYQ==?= Microsoft Access 0 13th Mar 2006 10:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:29 AM.