Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by peppiv (Curate)
on Feb 07, 2003 at 18:55 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-23 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found