Say I have a table with columns userId and videoId, representing which user watched which video in a video app. Now I want to get the view count and the unique view count from the table, but using only one query. Is this possible? Here's a visual of the example:
How can I get views and unique views from a database table that has only user id and video id in one query?
393 Views Asked by AskYous At
1
There are 1 best solutions below
Related Questions in SQL
- SQL schema for a fill-in-the-blank exercise
- Hibernate: JOIN inheritance question - why the need for two left joins
- What's supposed to be the problem in this query?
- Compare fields in two tables
- How to change woocomerce or full wordpress currency with value from USD to AUD
- Dynamic query creation with Array like implementation
- SQL query to get student enrolled in this month in a course - Moodle
- SQL LAG() function returning 0 for every row despite available previous rows
- Convert C# DateTime.Ticks to Bigquery DateTime Format
- Use row values from another table to select them as columns and establish relations between them (pivot table)
- SQL: Generate combination table based on source and destination column from same table
- how to use system's environnement variables in sql script
- PHP fetchAll on JOIN
- Multitable joining in Sql
- How to display name starting from 'z' by using BETWEEN cmd only?
Related Questions in UNIQUE
- How to dedupe numbers that are in sequence using Python
- algorithm to find n unique randomly selected coordinates
- PHP string comparison for unicity
- Find unique values in a column in R
- Excel Counting unique values within specific time interval
- Using GREL function uniques() to remove duplicates
- random unique list - not providing unique values in C#
- STL: Keeping Only Unique String Characters AND Preserving Order
- Excel - Count only instances of unique values in two columns
- Function Unique in Excel
- VBA to extract a unique list from Sheet 1 column N and list on sheet 2 column B based on a condition on sheet 1
- Unique list using first word in a string
- How to collapsed record into one based on start date and end date of record in R
- I need to write a filter function (I think) that returns a unique "ID" only if all "Type" ="b"
- How do I define a unique constraint in a diesel schema attribute
Related Questions in COMPOUND-KEY
- Can I create a third "value" on another table from the combined keys of a Bridge Table?
- Performance of filter+sort when filtering with a range on a compound key that has a key with many increments (like millisecond timestamps)
- 'Create a Campaign Conversion' linkedin API giving 'is not a Compound key' error with status 400
- Mysql key: is single key guaranteed to be faster than compound key?
- How can auto-Incrementing be maintained when concurrent transactions occur on a compound key In MYSQL?
- Microsoft Access - Using Concat related on a field with a compound key
- Optional unidirectional one to one relationship with compound key
- How to handle compound keys with Spring Data JDBC
- How can I get views and unique views from a database table that has only user id and video id in one query?
- Reinstantiating EF classes with one-to-many relationship and compound key of strings
- Clustering order does not work with compound partition key
- mongodb compound keys duplicate key error
- Realm compound key workaround by using complex object as primary key
- Compound key in Realm with lazy property
- pyspark reduce key being a tuple values nested lists
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?

Nevermind I figured it out. I ran the following query: