sql - Column "INVOICE.DATE_OF_ISSUE" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause -


could explain me i'm doing wrong? i'm completly new in , don't know do.

i'm trying show invoice : nr_invoice , invoice value, issued between 17 july 1995 , 24 july 1995, net value more 50, sorted date.

select invoice.nr_invoice, count(commodity.price) invoice full join line_invoice on invoice.nr_invoice = line_invoice.fnr_invoice  left join commodity on line_invoice.fid_towar = commodity.id_commodity invoice.date_of_issue between '1995-07-17' , '1995-07-24'   , commodity.price > 50 group invoice.nr_invoice order invoice.date_of_issue 

here error

column "invoice.date_of_issue" invalid in order clause because not contained in either aggregate function or group clause.

there no reason use outer joins query. where clause turning them inner joins anyway.

to solve particular problem, need either include date_of_issue in group by or use aggregation function:

select i.nr_invoice, count(c.price) invoice join      line_invoice li      on i.nr_invoice = li.fnr_invoice join      commodity c      on li.fid_towar = c.id_commodity i.date_of_issue between '1995-07-17' , '1995-07-24' ,       c.price > 50 group i.nr_invoice, i.date_of_issue order i.date_of_issue; 

edit:

your specific question is:

i'm trying show invoice : nr_invoice , invoice value, issued between 17 july 1995 , 24 july 1995, net value more 50, sorted date.

the query use having:

select i.nr_invoice, sum(c.price) invoice join      line_invoice li      on i.nr_invoice = li.fnr_invoice join      commodity c      on li.fid_towar = c.id_commodity i.date_of_issue between '1995-07-17' , '1995-07-24'  group i.nr_invoice, i.date_of_issue having sum(c.price) > 50 order i.date_of_issue; 

note: if have quantity value on invoice line, need take account.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -