oracle - SQL attribute variant within the same statement -


Having the following statement gives me 4 columns (location, description, guardian, count) depending on the situation:

  SELECT KINCIDENT.Location, LOCATIONS DESCRIPTION, LOCHIERARCHY PEPPER, CURRICULAR LOCATION, LOCATION, LOCHIERARCHY WHERE CANCER. Location = LOCATIONS.location and LOCATIONS.location = LOCHIERARCHY.location and Kinder. Status = Cancer by the 'ECCAPR' group. Location, LOCATIONS details, LOCHIERARCHY. Order by guardian; However, I want a 5th column that counts to me, but when I can specify KINCIDENT.status = 'FSAPR' instead, in which situation each counting column takes place ?   

Do you want conditional aggregation? Select the obvious join s:

  k.location, l.description, h.parent, SUM (case when using k.status = 'ECCAPR To learn how to do 'THEN 1 ELSE 0 END' join the cnt_ECCAPR, SUM (case when K.State = 'FSAPR' then 1 ELSE 0 END) from cnt_FSAPR to KINDICENT K. k.location = l. Location JOIN LOCHIERARCHY at l.location = h.location group by k.location, l.description, h.parent parent order;  

I have also introduced table alioles which generally make it easier to write and read questions.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -