Forum

Can you write a SQL...
 
Share:
Notifications
Clear all

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


Posts: 27
Admin
Topic starter
(@vinodkrsetty)
Eminent Member
Joined: 5 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
Posts: 1
Guest
(@Avinash)
New Member
Joined: 4 years 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

Self Learning Video Tutorials - Software Course

Leave a reply

Author Name

Author Email

Title *

Preview 0 Revisions Saved
Share: