• 0

[SQL] Need some help with a SQL Server 2008 queries


Question

1 - I have a table named Customer and it contains first and last names of customers. How can I display only the first letter of the customers' names as part of my results?

2 - There is a column which holds the date of joining a website as SmallDate. How can I calculate how long they have been members up through today?

Thanks! :D

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

1. SELECT SUBSTRING(first,1,1) FROM Customer

2. SELECT DATEDIFF(d,JoinDate column,GETDATE()) FROM Customer -- that's in days.

Edited by ozzy76
Link to comment
Share on other sites

  • 0

Both of them worked great!

One more question:

Say I'm setting up a CASE statement and I've used DATEDIFF up in the SELECT statement, how do I use the results of the DATEDIFF within the CASE statement?

Edit: Nevermind I got it working now! Thanks!

Edited by Crackler
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.