[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

phil2phil

3/19/2007 11:37:00 AM

hi,
i had a question on how to possibly select two things, not in the same
query.

1. We have data in a few columns of bit type, we enter in either 1 for
yes or 0 for no, is there anyway to do a select so that rather than
getting a 1 or 0 back the query returns a Y or N?

2. We also need to know the number of people entered per day, we have
a date_Created column, which tells us the date the record was entered,
which we can use. But the date in there is stored with time, example
2007-03-01 15:21:49 is there a way to do a group by without the time,
so i can do a count(*) and get the count per day?

Thanks

4 Answers

Razvan Socol

3/19/2007 11:46:00 AM

0

Hello, Phil

For the first question, try:

SELECT CASE YourColumn WHEN 1 THEN 'Y' WHEN 0 THEN 'N' END
FROM YourTable

For the second question:

SELECT DateCreated, COUNT(*) AS Cnt FROM (
SELECT DATEADD(day, DATEDIFF(day, 0, date_Created), 0)
FROM YourTable
) x GROUP BY DateCreated

or:

SELECT DateCreated, COUNT(*) AS Cnt FROM (
SELECT CONVERT(datetime, CONVERT(varchar(8),date_Created,112))
FROM YourTable
) x GROUP BY DateCreated

Razvan

Uri Dimant

3/19/2007 12:20:00 PM

0

Razvan
Just add an alias

SELECT DateCreated, COUNT(*) AS Cnt FROM (
SELECT DATEADD(day, DATEDIFF(day, 0, date_Created), 0) DateCreated
FROM YourTable
) x GROUP BY DateCreated





"Razvan Socol" <rsocol@gmail.com> wrote in message
news:1174304763.768714.12860@l75g2000hse.googlegroups.com...
> Hello, Phil
>
> For the first question, try:
>
> SELECT CASE YourColumn WHEN 1 THEN 'Y' WHEN 0 THEN 'N' END
> FROM YourTable
>
> For the second question:
>
> SELECT DateCreated, COUNT(*) AS Cnt FROM (
> SELECT DATEADD(day, DATEDIFF(day, 0, date_Created), 0)
> FROM YourTable
> ) x GROUP BY DateCreated
>
> or:
>
> SELECT DateCreated, COUNT(*) AS Cnt FROM (
> SELECT CONVERT(datetime, CONVERT(varchar(8),date_Created,112))
> FROM YourTable
> ) x GROUP BY DateCreated
>
> Razvan
>


Razvan Socol

3/19/2007 12:51:00 PM

0

Hi, Uri

Thanks for correcting this.

Razvan

phil2phil

3/19/2007 1:32:00 PM

0

Thanks all!