sql server - SQl , multiple questions ( parameters in a join and putting a column into a row -


i trying group table date (mm/yyyy) , invoicetype, have tried putting in code below keep getting error 'invalid column date'.

select right(convert(varchar(10), case_createddate, 103), 7) date,        case_invoicetype,        sum(case_totalexvat)   cases ca  case_primarycompanyid = 1111 group  ca.date,           case_invoicetype  

i tried this:

group year(case_createddate), month(case_createddate) 

but error:

case_createddate invalid in select list because not contained in either aggregate function or group clause

any ideas ?

thanks

you need include non aggregated columns select in group clause. ca.date not in select, suspect want this:

select right(convert(varchar(10), case_createddate, 103), 7) date,        case_invoicetype,        sum(case_totalexvat)   cases ca  case_primarycompanyid = 1111 group  right(convert(varchar(10), case_createddate, 103), 7),           case_invoicetype  

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -