Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Just another Perl shrine
 
PerlMonks  

Re: Re: Selecting and ordering data over multiple date ranges

by peppiv (Curate)
on Feb 07, 2003 at 18:55 UTC ( #233556=note: print w/ replies, xml ) Need Help??


in reply to Re: Selecting and ordering data over multiple date ranges
in thread Selecting and ordering data over multiple date ranges

Once again gmax you've made my day better. Check it out:

"SELECT state, SUM(case when identifier BETWEEN '2003-01-01' AND '2003 +-02-01' then 1 else 0 end) AS 'Jan', SUM(case when identifier BETWEEN + '2003-02-01' AND '2003-03-01' then 1 else 0 end) AS 'Feb', COUNT(*) +as TOTAL FROM contacts WHERE state != '' GROUP BY state ORDER BY 3 DE +SC"


The 'case' instead of IF works because it's on MSQl. Also, it requires the 'then 1 else 0 end'.

Works like a charm! Soooopa Thanx

peppiv


Comment on Re: Re: Selecting and ordering data over multiple date ranges
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://233556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-04-18 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (461 votes), past polls