sql - Outer Reference error when grouping month and years -


getting following error:

each group expression must contain @ least 1 column not outer reference 

i'd have listing of calculateddrugdistributionhistory grouped facilty, month, , year. want take inventory of facilities months have been imported our system.

i have query:

select      f.name,     month(cddh.dategiven) 'date_month',     year(cddh.dategiven) 'date_year'       calculateddrugdistributionhistory cddh         inner join facilityindividuals fi on fi.facilityindividualid = cddh.facilityindividualid         inner join facilities f on fi.facilityid = f.facilityid group      f.name,     'date_month',     'date_year' order     f.name,     'date_month',     'date_year' 

you can't use aliases in group clause. try way:

select      f.name,     month(cddh.dategiven) date_month,     year(cddh.dategiven) date_year  calculateddrugdistributionhistory cddh inner join facilityindividuals fi on fi.facilityindividualid = cddh.facilityindividualid inner join facilities f on fi.facilityid = f.facilityid group      f.name,     month(cddh.dategiven),     year(cddh.dategiven)  order     f.name,     date_month,     date_year 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -