Here I have a code for a view that has been created by a developer on my team. I am trying to use the very same code to create a view for a different formid/quesid. But I cannot figure out how this one starts and ends. can someone please help.
here's the code from the developer. -
SELECT a.EvalRecNo, w1.q1, w2.q2, w3.q3, w4.q4, w5.q5, w6.comment
-
FROM (SELECT DISTINCT u.EvalRecNo
-
FROM dbo.UData AS u INNER JOIN
-
dbo.EvalIssue AS e ON u.EvalRecNo = e.RecNo
-
WHERE (e.FormNo = 'R507') AND (e.DateComplete IS NOT NULL)) AS a LEFT OUTER JOIN
-
(SELECT u.EvalRecNo, u.NumAns AS q1
-
FROM dbo.UData AS u INNER JOIN
-
dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
-
WHERE (fq.QuesID = 858)) AS w1 ON a.EvalRecNo = w1.EvalRecNo LEFT OUTER JOIN
-
(SELECT u.EvalRecNo, u.NumAns AS q2
-
FROM dbo.UData AS u INNER JOIN
-
dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
-
WHERE (fq.QuesID = 859)) AS w2 ON a.EvalRecNo = w2.EvalRecNo LEFT OUTER JOIN
-
(SELECT u.EvalRecNo, u.NumAns AS q3
-
FROM dbo.UData AS u INNER JOIN
-
dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
-
WHERE (fq.QuesID = 860)) AS w3 ON a.EvalRecNo = w3.EvalRecNo LEFT OUTER JOIN
-
(SELECT u.EvalRecNo, u.NumAns AS q4
-
FROM dbo.UData AS u INNER JOIN
-
dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
-
WHERE (fq.QuesID = 861)) AS w4 ON a.EvalRecNo = w4.EvalRecNo LEFT OUTER JOIN
-
(SELECT u.EvalRecNo, u.NumAns AS q5
-
FROM dbo.UData AS u INNER JOIN
-
dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
-
WHERE (fq.QuesID = 862)) AS w5 ON a.EvalRecNo = w5.EvalRecNo LEFT OUTER JOIN
-
(SELECT u.EvalRecNo, u.TxtAns AS comment
-
FROM dbo.UData AS u INNER JOIN
-
dbo.UFormQuestion AS fq ON u.QuesFormID = fq.QuesFormID
-
WHERE (fq.QuesID = 865)) AS w6 ON a.EvalRecNo = w6.EvalRecNo
-
******************************
I'd like to do the exact same thing with this code: -
select b.quesid, b.formno, b.questext, d.numans, d.txtans from uquestionbank b, uformquestion f, udata d
-
where b.quesid = f.quesid
-
and f.quesformid = d.quesformid
-
and b.formno = 'R102'
-
and f.quesid in (486,519,522)
Can someone please tell me how the first query works because everytime I try to interpret it and make my own - i end up in circles.
Thank you,
1 4579
The first query is a inline view and the view is based on a number of joins.
Refer the person who has developed it because i don't have any idea of your table structure.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Justin Hennessy |
last post by:
Hi all,
I am working with a computer hardware asset database and I am trying to get
information out of it for each PC in my organisation.
Here is the basic table structure:
Table1 -> Table2...
|
by: Thomas Beutin |
last post by:
Hi,
i've a speed problem withe the following statement:
SELECT DISTINCT pz.l1_id, pz.l2_id, pz.l3_id, pz.l4_id
FROM ot_adresse AS a, ot_produkt AS p
LEFT OUTER JOIN ot_kat_prod AS pz ON (...
|
by: Bob Alston |
last post by:
I am trying to use an access sql statement in a module that does a left
outer join on one table - joined to a table that has a selection
criteria. The result is an inner join.
If I do this in...
|
by: Doug |
last post by:
Hi,
I'm more familiar with MSSQL than Access syntax and have run into a problem
with correctly putting ( )'s around the joins in a 3 table query. I want to
INNER JOIN lenders and accounts and...
|
by: media.opslag |
last post by:
Hi,
How can i get this to work in access / jet sql ??? Someone??
SELECT
tbl1.,
tbl2.
FROM tbl1
left outer join tbl2 on
|
by: tricard |
last post by:
Good day all,
I have a large outer joined query that I want to have some criteria.
The select query is gathering all part numbers from tblPartNumbers,
left joining to tblPartNumberVendor (since...
|
by: rrstudio2 |
last post by:
If I have two tables and need to do a left outer join and include a
where statement on the second table, it seems like the left outer join
becomes an inner join. For example:
Table: Names
id...
|
by: polycom |
last post by:
Assistance needed to optimize this query
SELECT SD.content_id AS Id,
SD.title AS Title,
CT.name AS Contenttype,
PV.content_id AS SponsorId,
...
|
by: shapper |
last post by:
Hello,
I am used to SQL but I am starting to use LINQ.
How can I create Left, Right and Inner joins in LINQ? How to
distinguish the different joins?
Here is a great SQL example:...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |