Skip to content
Advertisement

Tag: distinct

sql query distinct with Row_Number

I am fighting with the distinct keyword in sql. I just want to display all row numbers of unique (distinct) values in a column & so I tried: however the below code giving me the distinct values: but when tried it with Row_Number. then it is not working. Answer Use this: and put the “output” of a query as the

GROUP BY and COUNT in PostgreSQL

The query: Returns n records in Postgresql: I just want to retrieve the number of records returned: 6. I used a subquery to achieve what I want, but this doesn’t seem optimum: How would I get the number of records in this context right in PostgreSQL? Answer I think you just need COUNT(DISTINCT post_id) FROM votes. See “4.2.7. Aggregate Expressions”

SQL query to find distinct values in two tables?

I would like to find the distinct Code values and get a return like this: I can’t figure out how to write a SQL query that would return me the above results. Anyone have any experience with a query like this or similar? Answer In proper RDBMS: In MySQL… the UNION removes duplicates

Advertisement