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, 2012 at 09:08 AM in Default

avatar image

dharmendra1
20 4 4 7

(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, 2012 at 12:17 PM

avatar image

Fatherjack ♦♦
43.7k 79 98 117

(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

SQL Server Central

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

Topics:

x104

asked: Jul 23, 2012 at 09:08 AM

Seen: 922 times

Last Updated: Jul 23, 2012 at 12:17 PM

Copyright 2016 Redgate Software. Privacy Policy