x
login about faq Site discussion (meta-askssc)

How to rename resultset

I have a query like this

SELECT date_format( doj, '%d/%m/%Y' ) AS week ,
COUNT(user_id) 
FROm user_tb 
WHERE doj between '2012-01-01' 
AND '2012-01-31' 
group BY WEEK(doj)

Result

week COUNT(user_id)
06/01/2012 3
17/01/2012 2
25/01/2012 3
29/01/2012 1

How can I name it like this
week COUNT(user_id)
week1 3
week2 2
week3 3
week4 1

more ▼

asked Jul 23 '12 at 09:08 AM in Default

dharmendra1 gravatar image

dharmendra1
20 1 2 5

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

In mySQL? No idea.

In TSQL - SELECT DATEPART(wk,GETDATE()) returns 31 - ie the 31st week since the start of the calendar year.

Hopefully this will help you search for the relevant solution in mySQL

more ▼

answered Jul 23 '12 at 12:17 PM

Fatherjack gravatar image

Fatherjack ♦♦
38.8k 55 69 104

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x52

asked: Jul 23 '12 at 09:08 AM

Seen: 283 times

Last Updated: Jul 23 '12 at 12:17 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.