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:
Tag: sql
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
SQL query to get all data for a particular user
I have two tables: Users (idk, surnamek, namek, logink), Measurements (idm, date, weight, #idk) I need to create a query to get all measurements for a particular logink. Answer use inner join:
Correction Needed for error in Oracle query
I want calculate the all students credit hours separately group by stduents of each? needed help to correction of query Answer Try this:
Select unmatched records from two tables with a filter on second table
I have 2 mysql tables a and b. I need to show all records in a that are not in b using a common column ‘ID’. Normally this is pretty straight forward but my problem here is this: I need to put a where clause on table b because I’m not interested in all unmatched records just the ones that
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
Getting student name with highest total mark in SQL
I have table named ‘marks’ which stores marks of students. I want to get the name of student who has highest total mark. I tried query like this But this is not working. Can anyone please help ? Answer get the max() total first then use a subquery
How to use temp table in SQL Server script?
I have to use some hardcode data in sql script, for this I am using temp table On line 6, it is showing error as Expecting Id Is there any simplest way to do this? Answer There is no double data type in sql server use decimal.