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

2 Posts
2 Users
0 Likes
464 Views
KV Kumar
Posts: 27
Admin
Topic starter
(@vinodkrsetty)
Eminent Member
Joined: 3 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
Guest
(@Avinash)
New Member
Joined: 2 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

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: