on 2018 May 09 9:37 PM
Hi Experts , Could you please help me on below query as i didn't get result as expected .
Query :
No. of users with who have never placed an order
SELECT COUNT(*) FROM ({{ SELECT DISTINCT({u.pk}) FROM {User as u JOIN Order as o ON {u.pk} = {o.user} } WHERE {Order} is null }}) as x
Really appreciated for reply
Request clarification before answering.
Hi Satish,
Please try this query instead:
SELECT COUNT(*) FROM {User as u} WHERE NOT EXISTS ({{ SELECT {pk} from {Order as o} WHERE {o.user} = {u.pk} }})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All , Could anyone help or guide me on below query as i need to do this one :
No. of users who have not placed an order in 5 days ".
SELECT COUNT(*) FROM {User as u} WHERE {o.modifiedtime} < NOW() - INTERVAL 5 DAY ({{ SELECT {pk} from {Order as o} WHERE {o.user} = {u.pk} }}).
I tried this one above query but its not working fine as expected .
Really help if anyone able to guide on above query .......
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pablo, Thanks for your reply . Could you please guide me more one below query if possible :
"No. of users who have not placed an order in 5 days ".
SELECT COUNT(*) FROM {User as u} WHERE {o.modifiedtime} < NOW() - INTERVAL 5 DAY ({{ SELECT {pk} from {Order as o} WHERE {o.user} = {u.pk} }})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.