x

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 4 4 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 ♦♦
41.3k 73 77 107

(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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x65

asked: Jul 23 '12 at 09:08 AM

Seen: 654 times

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