Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / December 2007

Tip: Looking for answers? Try searching our database.

Use of MONTH() function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
paulvonhippel@yahoo.com - 05 Dec 2007 19:41 GMT
I'd like to count the number of transactions for each debit card and
month over a 3-month period.

But this query --

select DBT_CRD_DIM_NB,
        month (tran_dt) as tran_mnth,
        count(*) as txns_per_crd_mnth
 from cdwdba.VW_DCM_EB_DLY_ALL_TRN_MSR
 where tran_dt between '2007-08-01' and '2007-10-31'
 group by DBT_CRD_DIM_NB, tran_mnth

-- returns this error:

[IBM][CLI Driver][DB2/AIX64] SQL0206N  "TRAN_MNTH" is not valid in the
      context where it is used

I haven't used the MONTH() function, before and clearly I must be
using it wrong. Many thanks for any advice.

Paul
Tomas - 05 Dec 2007 20:06 GMT
Paul,

try grouping by month(tran_dt) instead of the correlation name.

/T

On Dec 5, 11:41 am, paulvonhip...@yahoo.com wrote:
> I'd like to count the number of transactions for each debit card and
> month over a 3-month period.
[quoted text clipped - 17 lines]
>
> Paul
CRPence - 05 Dec 2007 20:09 GMT
Repeat the expression in the GROUP BY clause.  It is not the MONTH()
function [expression], but with any expression.  For the given
expression, the scalar function month(tran_dt), the corrected GROUP BY:
    group by DBT_CRD_DIM_NB, month (tran_dt)

Regards, Chuck
Signature

 All comments provided "as is" with no warranties of any kind
whatsoever and may not represent positions, strategies, nor views of my
employer

> I'd like to count the number of transactions for each debit card and
> month over a 3-month period.
[quoted text clipped - 15 lines]
> I haven't used the MONTH() function, before and clearly I must be
> using it wrong. Many thanks for any advice.
paulvonhippel@yahoo.com - 05 Dec 2007 21:09 GMT
That did it! Thank you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.