[mso] Re: AccessSQL
- From: "Clint Graham" <Clint.Graham@xxxxxxxxxxxxxxxxxx>
- To: <mso@xxxxxxxxxxxxx>
- Date: Thu, 21 Jul 2005 17:57:47 +0100
Sorry about that some wierd settings in this emsil
Hopefully you can read it now
Simplest way would be to do a query that brought back latest (i.e. max comid)
comid with "em" in where (or criteria in design view). Do the same again in a
new query but with "ph" in where. So far this can be done using design view.
Next switch both queries to sql view. copy the code from the first query into a
new sql query window. Remove the semi colon put in a cartridge return or 2 (for
readability) insert the word "union" again add a couple of lines space. Then
copy the second sql query statement. This time make sure you have the semi
colon terminating your statement. To make sure that "em" entry follows "ph" use
the order by clause and order by UID (or other fields if you are combining with
other tables). Not the most elegant solution but should work well enough and
doesn't require much skill.
Hope that helps
Clint
-----Original Message-----
From: mso-bounce@xxxxxxxxxxxxx [ mailto:mso-bounce@xxxxxxxxxxxxx]On
Behalf Of Glenda Wells
Sent: 19 July 2005 20:20
To: mso@xxxxxxxxxxxxx
Subject: [mso] Re: AccessSQL
Thanks. It's a place to start Jim. Naturally, there are other scenarios
to workout like the kid who doesn't have any email addresses or the kid
who doesn't provide a telephone number. I think I need a couple of OR
statements. Sheesh, this stuff can get really complicated!...it's gonna
be a lonnngh week.
-----Original Message-----
From: Jim Pettit [ mailto:jimpettit@xxxxxxxxx]=20
Sent: Monday, July 18, 2005 06:11 PM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Re: AccessSQL=20
Glenda--
How about this?:
SELECT tblCOMM.UID, em.comm AS email, tblCOMM.comm AS phone FROM tblCOMM
INNER JOIN [SELECT tblCOMM.UID, tblCOMM.commID, tblCOMM.comm FROM
tblCOMM WHERE (((tblCOMM.commID) In (SELECT max(commid) from tblComm
where
type=3D'em')) AND ((tblCOMM.type)=3D"em"))]. AS em ON tblCOMM.UID =3D =
em.UID
WHERE (((tblCOMM.type)=3D"ph") AND ((tblCOMM.active)=3D-1));
--Jim=20
-----Original Message-----
From: mso-bounce@xxxxxxxxxxxxx [ mailto:mso-bounce@xxxxxxxxxxxxx] On
Behalf Of Glenda Wells
Sent: Monday, July 18, 2005 8:47 AM
To: mso@xxxxxxxxxxxxx
Subject: [mso] AccessSQL=20
I'm still feeling my way around writing SQL queries in reports and
appreciating all ya'll helping.
I have telephone and email in the same table
I'd like to extract the most recent email by commID (this would be the
maximum record) and the Active telephone of which there can only be one.
I THINK this needs a query/subquery with a join to get the max email as
well as another subquery to get the active phone.
Here's what the table looks like
tblCOMM
UID commID type active comm
A001 1001 em gwells@xxxxxxxxxxx
A001 1002 em gwells@xxxxxxx
A001 1003 em gwells@xxxxxxx
A001 1004 ph -1 386-822-7088
A001 1005 ph 386-822-7126
My desired result is
UID, email, phone
A001, gwells@xxxxxxx, 386-822-7088
I have this which (I hope) gets me the email address but how do I get
phone number too?
SELECT tblCOMM.UID, tblCOMM.comm
FROM tblCOMM
WHERE (((tblCOMM.UID)=3D3D(SELECT
max(b.commID) FROM tblCOMM b WHERE b.UID =3D3D tblCOMM.UID)) AND
((tblCOMM.type)=3D3D"em"));
*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx
or MicrosoftOffice@xxxxxxxxxxxxxxxx
To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
To Unsubscribe from this group, send an email to
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the
quotes) in the subject line.
Or, visit the group's homepage and use the dropdown menu. This will
also allow you to change your email settings to digest or vacation (no
mail).
http://www.freelists.org/webpage/mso
To be able to use the files section for sharing files with the group,
send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an
invitation with instructions. Once you are a member of the files group,
you can go here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************
*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx
or MicrosoftOffice@xxxxxxxxxxxxxxxx
To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
To Unsubscribe from this group, send an email to
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the
quotes) in the subject line.
Or, visit the group's homepage and use the dropdown menu. This will
also allow you to change your email settings to digest or vacation (no
mail).
http://www.freelists.org/webpage/mso
To be able to use the files section for sharing files with the group,
send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an
invitation with instructions. Once you are a member of the files group,
you can go here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************
*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx
To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
To Unsubscribe from this group, send an email to
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in
the subject line.
Or, visit the group's homepage and use the dropdown menu. This will also allow
you to change your email settings to digest or vacation (no mail).
http://www.freelists.org/webpage/mso
To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with
instructions. Once you are a member of the files group, you can go here to
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************
This message is intended only for the use of the person(s) ("the intended
recipient(s)") to whom it is addressed. It may contain information that is
privileged and confidential within the meaning of applicable law. If you are
not the intended recipient, please contact the sender as soon as possible. The
views expressed in this communication may not necessarily be the views held by
Liberty Syndicate Management Limited.
This message may contain material non-public information. As such it should
not be used for the purchase or sale of any securities issued by either the
company or the Liberty Mutual Group, or their respective subsidiaries or
affiliates. Such prohibited use may subject one to both criminal and civil
penalties under governing laws.
*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx
To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
To Unsubscribe from this group, send an email to
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in
the subject line.
Or, visit the group's homepage and use the dropdown menu. This will also allow
you to change your email settings to digest or vacation (no mail).
http://www.freelists.org/webpage/mso
To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with
instructions. Once you are a member of the files group, you can go here to
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************
Other related posts: