Sedang Disiapkan

SQL Join Query

I am working on a basic project right now and having some issues with a query, or should I say part of a query. Not sure the best way to go to resolve it. Looked at Union All and Left Outer Joins. Basically have two tables. The first is a table listing project details for construction. The second table lists the project activity associations. The primary key on the first table is the Project ID and joins to the second table with the project ID too. Here is the problem. For each project there are many different activity dates associated. All use the same field name called EndDate on the Activity Associaction Table. The Activity Association table has an Activity ID for each type. Here are the types on that table I am trying to track. Please note that it is a one to many relationship and not all projects will have all the activities below.

EndDate AS DEV_MEETING_DATE WHERE ActivityID = 4

EndDate AS SITE_DEV_CHKLST_DATE WHERE ActivityID = 5

EndDate AS PLOT_DATE WHERE ActivityID = 7

EndDate AS PERMIT_DATE WHERE ActivityID = 9

EndDate AS CONSTRUCTION_START_DATE WHERE ActivityID = 12

EndDate AS SUBSTNTL_COMP_DATE WHERE ActivityID = 16

EndDate AS RET_SAVE_MEET_DATE WHERE ActivityID = 52

EndDate AS PLAN_APPROVE_VP_DATE WHERE ActivityID = 78

EndDate AS PLAN_APPROVE_PRES_DATE WHERE ActivityID = 59

EndDate AS PERMIT_SUBMIT_DATE WHERE ActivityID = 68

EndDate AS PERMIT_RECEIVE_DATE WHERE ActivityID = 69

EndDate AS REMODE_START_DATE WHERE ActivityID = 72

EndDate AS SUBST_COMP_DATE WHERE ActivityID = 75

So, if I wanted the Developer Meeting Date for all projects (even if no date assigned yet) I would have

SELECT

[url removed, login to view] as SITEID,

[url removed, login to view] AS DEV_MEETING_DATE

FROM ProjectDetails AS PD

LEFT OUTER JOIN ProjectActivityAssoc AS PAA

ON [url removed, login to view] = [url removed, login to view]

Where [url removed, login to view] = 4

To sum it up, I am trying to keep from doing 13 LEFT OUTER JOINs if possible.

Kemahiran: SQL

Lihat lebih lanjut: union first, n query, sql projects, query table, paa, sql different, sql select select, join project, sql select, sql problem, joins, query query, primary key, sql query field, sql query sum, project sql query, project query, sql query project, track activities, basic SQL , sql wanted, sql developer projects, sql table field, sql query date, sql project query

Tentang Majikan:
( 3 ulasan ) Auburndale, United States

ID Projek: #1582848

Dianugerahkan kepada:

OShuqair

Hello Sir, please checkout my message

$10 USD / jam
(17 Ulasan)
5.4

3 freelancers are bidding on average $8/hour for this job

manhpham

I am ready to help you.

$8 USD / jam
(11 Ulasan)
4.3
abbasitech

Hi there, Can fix it for you. Read private message for details. Thanks and Regards, ABBASITECH (IT SOLUTIONZ ISB)

$7 USD / jam
(2 Ulasan)
1.0