Skip to content
Advertisement

Tag: left-join

Count rows after joining three tables in PostgreSQL

Suppose I have three tables in PostgreSQL: Suppose I am using the using the following query: I get 50 as count. Whereas with: I get only 25 as count. What is my mistake in the second query? What can I do to get the same count? My requirement is that there is a single user table, referenced by multiple tables.

Counting number of joined rows in left join

I’m trying to write an aggregate query in SQL which returns the count of all records joined to a given record in a table; If no records were joined to the given record, then the result for that record should be 0: Data My database looks like this (I’m not able to change the structure, unfortunately): (MESSAGEPART has a composite

Advertisement