postgresql - SQL finding part of common and differences under some conditions -
First of all, I will describe the whole idea that I have a system which is about projects
There are many topics
in each project, every project is modified every month. For example:
2014-01-01 Project '1' was added to 40 topics 2014-01-01 Project '2' in relation to 120 topics added 2014-02 - 01 was added to project '1' in relation to 30 subjects 2014-02-01 Project '2' was added in relation to 100 subjects
I have discussed differences between topics I want to count, how many of them are new, how many of them have ended, and how many of them are still going on
I Try it as
Create a question. Table structure:
database = & gt; \ D Project Tabela "public.project" Kolumna | Type | Modifiktree ---------------- + --------- + ---------------------- ----------------------------------- ID | Integer | Nephitius Dominici Agvalewell ('project_ id_seq' :: regclass) skid | Integer | Beginners Date | Database = & gt; \ D topic Tabela "public.topic" Kolumna | Type | Modifiktree ---------------- + --------- + ---------------------- ------------------------------- ID | Integer | Nefishial Dominici Agvalewell ('topic_id_seq' :: Regclass) Project _id | Integer | Topicengine_id | Integer | Parameter | Text | Details | Text | Seriousness Text | Need_id | Integer | Topic_im | Integer |
In my first try is counting
with the topics included:
SELECT t1.id from topic t1 INNER Insert Topic T2 On T.ID = T 2. Made Inner Gene Project P1 On P. 1. ID = T1 POJCT_ID Inner Generate P2 On P 2. ID = T 2.project_id WHERE p1.id = 1101 and P2.id = 1168
However each time the result is zero. Does anyone tell me that I'm making a mistake?
The primary ID seems to be the primary key for the subject. This means that it includes: t1.id = t2.id
is included in the record with yourself and hence t1.project_id is equal to t2.project_id and can not have two values at the same time . Maybe you mean to join T1 and T2 on topicengine_id?
Comments
Post a Comment