The customers table after performing the above insertions looks something as follows:. Find the customer ids of all the unique customers who have bought or ordered something from the departmental store. This can be observed in this example also. Find the sum of revenue collected for all the unique orders that were made on a particular date at a particular store of the departmental store.
Find all the unique customers and the sum of total money spent by them at the departmental store. You can also go through our suggested articles to learn more —. Submit Next Question. Here's a screenshot in Navicat Premium 's Grid view that shows a customer that has 2 associated emails:.
We can then select other columns by joining the email column to the unique ones returned by the sub-query:. Another, albeit slightly more advanced solution, is to use a Window function. Window functions are thus named because they perform a calculation across a set of table rows that are related to the current row.
Unlike regular aggregate functions, window functions do not cause rows to become grouped into a single output row so that the rows retain their separate identities. Assuming there was user with two roles then the above query will return two records with the same user name. This article has more detail. First selects all the 'available records' and then it 'removes duplicate records' in all 'available records' and prints. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Ask Question. Asked 9 years, 9 months ago. Active 8 years, 1 month ago. Viewed 14k times.
0コメント