Skip to content
Advertisement

Tag: sql

Count double occurrences in order list

I have a list of orders, I need to find which ones occur with code 47 more than once with different users. For example: The expected result is 111 and 333. How can I accomplish this? Regards Answer I think you want aggregation and having: You can also express the having as:

How to identity customer orders by customer IDs [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question Say for example I have table Customer and I have another table called orders. How to identify that each order belongs to that particular customer.

MYSQL Query calculate percentage of emails not null

I have these two queries. Caluculates count of emails that are null SELECT COUNT(*) as invalid_email FROM distinct_customers WHERE c_email IS NULL; Calculates count of every email SELECT COUNT(distinct c_number) as total FROM distinct_customers; I am trying to combine those to queries so that it gives me a percentage of valid emails (not null) I tried a couple of ways

Group by question in SQL Server, migration from MySQL

Failed finding a solution to my problem, would love your help. ~~ Post has been edited to have only one question ~~- Group by one query while selecting multiple columns. In MySQL you can simply group by whatever you want, and it will still select all of them, so if for example I wanted to select the newest 100 transactions,

SQL join table with 12 column composite PK with itself painlessly

I have a table with a composite natural primary key that involves 12 columns (c1, c2, …, c12). I want to write a self join query: This join is a pain to write. Is there a better way? Answer Personally, if you must have a 12 column “key”, I would DROP that key, and create a computed column that concatenates

Advertisement