Ask a Question related to ASP Database, Design and Development.
-
Robert J Egan #1
Joining these two queries
Can anyone help me to join Query 1 to Query 2
cheers
rob
Query 1
-------------
SELECT * FROM
(SELECT COUNT(DISTINCT RLID) AS NoBooked, SUM(PlacesNo) AS NoPlacesTaken,
RL.EID, V.EventPlaces, CAST (V.EventPlaces-SUM(PlacesNo) AS Int) AS
PlacesAvailable
FROM tbl_ep_Returns_List RL, tbl_ep_Venue V
WHERE RL.Status <= 2 AND RL.EID = 4 AND RL.EID = V.EID
GROUP BY RL.EID, V.PlacesMax, V.PlacesMin, V.EventPlaces)
tbl_tmp1
WHERE EID = 4
Query 2
---------------
SELECT EID, Status AS TheStatus, RLID, PlacesNo, FName, LName, Organisation,
RecievedDate, JobRole
FROM dbo.tbl_ep_Returns_List
WHERE RLID = 22
Robert J Egan Guest
-
Help needed with Joining 2 Queries together
hi all. i've got the following two queries and i'd like to combine them into one, and i just can't figure it out. hoping someone here can get the... -
Joining three tables
Hello all, I am having a bear of a time trying to join three tables in Sybase. Here is the query...... select DISTINCT(appl.ag_id),... -
Queries Of Queries Single Quote Problem
When using queries of queries I'm having the following issue. Select Company_ID From qry_MyQuery Where Company_NM = 'MyString''s' <----... -
Joining Paths or joining two shapes
Hi, I have drawn threeleaves with the pen tool (closed paths). I would like to join these leaves to make a flower into which I want to place an... -
help with joining 2 images together
I would like to know if anyone can suggest a way of joining 2 images side by side without a straight line between the images. Like feathering... -
Bob Barrows #2
Re: Joining these two queries
Assuming this is SQL Server(what version, please?)
Select * FROM
(Query1) q1
INNER JOIN
(Query2) q2
ON q1.<joining column> = q2.<joining column>
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From header is
my spam trap, so I don't check it very often. You will get a quicker
response by posting to the newsgroup.
"Robert J Egan" <rob_j_egan@hotmail.com> wrote in message
news:epRgTPs2DHA.2544@TK2MSFTNGP10.phx.gbl...Organisation,> Can anyone help me to join Query 1 to Query 2
>
> cheers
> rob
>
> Query 1
> -------------
>
> SELECT * FROM
>
> (SELECT COUNT(DISTINCT RLID) AS NoBooked, SUM(PlacesNo) AS NoPlacesTaken,
> RL.EID, V.EventPlaces, CAST (V.EventPlaces-SUM(PlacesNo) AS Int) AS
> PlacesAvailable
> FROM tbl_ep_Returns_List RL, tbl_ep_Venue V
> WHERE RL.Status <= 2 AND RL.EID = 4 AND RL.EID = V.EID
> GROUP BY RL.EID, V.PlacesMax, V.PlacesMin, V.EventPlaces)
>
> tbl_tmp1
>
> WHERE EID = 4
>
> Query 2
> ---------------
>
> SELECT EID, Status AS TheStatus, RLID, PlacesNo, FName, LName,> RecievedDate, JobRole
> FROM dbo.tbl_ep_Returns_List
> WHERE RLID = 22
>
>
Bob Barrows Guest
-
Robert J Egan #3
Re: Joining these two queries
Hi thanks for replying Bob you assumed right. I'm using Version 7.
Using the below i got the following "Incorrect syntax near the keyword
'ON'."
I used the following
SELECT * FROM
(SELECT COUNT(DISTINCT RLID) AS NoBooked, SUM(PlacesNo) AS NoPlacesTaken,
RL.EID, V.EventPlaces, CAST (V.EventPlaces-SUM(PlacesNo) AS Int) AS
PlacesAvailable
FROM tbl_ep_Returns_List RL, tbl_ep_Venue V
WHERE RL.Status <= 2 AND RL.EID = 4 AND RL.EID = V.EID
GROUP BY RL.EID, V.PlacesMax, V.PlacesMin, V.EventPlaces)
q1
INNER JOIN
(SELECT EID, Status AS TheStatus, RLID, PlacesNo, FName, LName,
Organisation, RecievedDate, JobRole
FROM dbo.tbl_ep_Returns_List
WHERE RLID = 22)
ON q1.EID = q2.EID
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:ur3XJzs2DHA.2556@TK2MSFTNGP10.phx.gbl...is> Assuming this is SQL Server(what version, please?)
> Select * FROM
> (Query1) q1
> INNER JOIN
> (Query2) q2
> ON q1.<joining column> = q2.<joining column>
>
> Bob Barrows
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From headerNoPlacesTaken,> my spam trap, so I don't check it very often. You will get a quicker
> response by posting to the newsgroup.
> "Robert J Egan" <rob_j_egan@hotmail.com> wrote in message
> news:epRgTPs2DHA.2544@TK2MSFTNGP10.phx.gbl...> > Can anyone help me to join Query 1 to Query 2
> >
> > cheers
> > rob
> >
> > Query 1
> > -------------
> >
> > SELECT * FROM
> >
> > (SELECT COUNT(DISTINCT RLID) AS NoBooked, SUM(PlacesNo) AS> Organisation,> > RL.EID, V.EventPlaces, CAST (V.EventPlaces-SUM(PlacesNo) AS Int) AS
> > PlacesAvailable
> > FROM tbl_ep_Returns_List RL, tbl_ep_Venue V
> > WHERE RL.Status <= 2 AND RL.EID = 4 AND RL.EID = V.EID
> > GROUP BY RL.EID, V.PlacesMax, V.PlacesMin, V.EventPlaces)
> >
> > tbl_tmp1
> >
> > WHERE EID = 4
> >
> > Query 2
> > ---------------
> >
> > SELECT EID, Status AS TheStatus, RLID, PlacesNo, FName, LName,>> > RecievedDate, JobRole
> > FROM dbo.tbl_ep_Returns_List
> > WHERE RLID = 22
> >
> >
>
Robert J Egan Guest
-
Bob Barrows #4
Re: Joining these two queries
Robert J Egan wrote:
You left out the q2 alias:> Hi thanks for replying Bob you assumed right. I'm using Version 7.
>
> Using the below i got the following "Incorrect syntax near the keyword
> 'ON'."
>
>
> I used the following
>
> SELECT * FROM
>
> (SELECT COUNT(DISTINCT RLID) AS NoBooked, SUM(PlacesNo) AS
> NoPlacesTaken, RL.EID, V.EventPlaces, CAST
> (V.EventPlaces-SUM(PlacesNo) AS Int) AS PlacesAvailable
> FROM tbl_ep_Returns_List RL, tbl_ep_Venue V
> WHERE RL.Status <= 2 AND RL.EID = 4 AND RL.EID = V.EID
> GROUP BY RL.EID, V.PlacesMax, V.PlacesMin, V.EventPlaces)
>
> q1
>
> INNER JOIN
>
> (SELECT EID, Status AS TheStatus, RLID, PlacesNo, FName, LName,
> Organisation, RecievedDate, JobRole
> FROM dbo.tbl_ep_Returns_List
> WHERE RLID = 22)
>
> ON q1.EID = q2.EID
>
>
WHERE RLID = 22) q2
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows Guest
-
Robert J Egan #5
Re: Joining these two queries
It works!
Thanks Bob, you've been a great help for me.
rob :)
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:ew$2pX12DHA.1908@TK2MSFTNGP10.phx.gbl...> Robert J Egan wrote:> You left out the q2 alias:> > Hi thanks for replying Bob you assumed right. I'm using Version 7.
> >
> > Using the below i got the following "Incorrect syntax near the keyword
> > 'ON'."
> >
> >
> > I used the following
> >
> > SELECT * FROM
> >
> > (SELECT COUNT(DISTINCT RLID) AS NoBooked, SUM(PlacesNo) AS
> > NoPlacesTaken, RL.EID, V.EventPlaces, CAST
> > (V.EventPlaces-SUM(PlacesNo) AS Int) AS PlacesAvailable
> > FROM tbl_ep_Returns_List RL, tbl_ep_Venue V
> > WHERE RL.Status <= 2 AND RL.EID = 4 AND RL.EID = V.EID
> > GROUP BY RL.EID, V.PlacesMax, V.PlacesMin, V.EventPlaces)
> >
> > q1
> >
> > INNER JOIN
> >
> > (SELECT EID, Status AS TheStatus, RLID, PlacesNo, FName, LName,
> > Organisation, RecievedDate, JobRole
> > FROM dbo.tbl_ep_Returns_List
> > WHERE RLID = 22)
> >
> > ON q1.EID = q2.EID
> >
> >
>
> WHERE RLID = 22) q2
>
>
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
Robert J Egan Guest



Reply With Quote

