cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Flexible Search

Former Member
0 Likes
388

Hi Experts , Could you please help me in 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} }})

Thanks in advance ....

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Likes

Hi Deepak, Thanks for your reply . but its difficult for me as you said ....i tried but its not worked still .

Former Member
0 Likes

if second one is working fine you can just count the total no of user id you are getting in result .it will be unique values and you can minus the no of result from total no of users brother.....

Former Member
0 Likes

Hi Deepak, Thanks for your reply again . 2nd query provided is working as u said but 1st one throwing some error whenever try to excute : "SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near ".": line 1 col 21 (at pos 21)" If you suggest more on this , it would be too help for me .

Former Member
0 Likes

select count{u.uid} from {order as o join user as u on {o.user}={u.pk}} where {o.creationTime} >'2018-05-09 00:00:00'

it will give you the no of users who have orders for the last 5 days.minus this no from the total no of users you will have your solution.

it is to see the user id which have placed order in the last 5 days. select distinct{u.uid} from {order as o join user as u on {o.user}={u.pk}} where {o.creationTime} >'2018-05-05 00:00:00'

Former Member
0 Likes

Hi Deepak, Thanks for your reply . But its still not working ....Where condition not working perfectly for not placed order in last 5 days .

Former Member
0 Likes

can we use date like this "05-05-2018" ?