Skip to content
Advertisement

Tag: 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.

How to retrieve count of records in SELECT statement

I am trying to retrieve the right count of records to mitigate an issue I am having. The below query returns 327 records from my database: Where I run into trouble is trying to reconcile that with the below query. One is for showing just a count of all the particular students the other is showing pertinent information for a

MySQL Query join last comment to topic

I have a topic and topic_comments table. I want to join them both. The join is on topic.id = topic_comments.parent_id. I want to show the topic with latest comment and order by latest comment createdate. And not show duplicate topics. Can anyone help me? So far I have this: This however doesn ‘t show topics without comments. It only returns

Select info from a table referencing info from another table

I have a main product table with different products. Different products have different specs, so I’ve created separate specs tables for each product (there will be more than ten of them). What I want to do is to show individual product’s specs on a product_page.php whenever the product is clicked. My product page has columns: My specs table columns So

inflation calculation in MS SQL

I have the below requirement to fulfill. How to achieve this simplistically. There is an inflation rate table as below I need to first get And then get Answer I think the best way to do this on SQLserver is to use a common table expression with recursion. I’m not 100% sure because I can’t test it here, but something

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