Forum

Can you write a SQL...
 
Notifications
Clear all

Can you write a SQL for this? Given the two tables below user and user history


KV Kumar
Posts: 27
Admin
Topic starter
(@vinodkrsetty)
Member
Joined: 2 years ago

User

-------------

User_ID

Name

Phone_Number

 

User History

--------------

User_ID

Date

Action

 

Question: Write an SQL query that returns the name, phone number and most recent date for any user that has logged in over the last 30 days (you can tell a user has logged in if the action field in User History is set to "logged_on").

1 Reply
Avinash
Posts: 1
 Avinash
(@Avinash)
Joined: 1 year ago

Select A. name, A. Phone_number, datediff(day, getdate(), date) as different

From User as A

Inner Join User History as B

ON A. User_id=B.User_id

Where different 1 between 30 

Order by date desc;

Reply
Share: