Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Syntax for group functions (COUNT, SUM, MIN, MAX, AVG)  (Read 2252 times)

HulkHagen

  • Newbie
  • *
  • Posts: 4
    • View Profile
Syntax for group functions (COUNT, SUM, MIN, MAX, AVG)
« on: March 02, 2022, 11:14:36 am »
Hello everybody

I am trying to use the COUNT-function but without success. I was not able to find anything function-related in the user manual. What is the correct syntax? What is the purpose of the "DataBand"-Parameter? Is it the band where the query is located in? Or the band the result is displayed? Or the target band where the amount should be displayed?

My goal: I want to output a list of serials in a text field AND display the amount of serials in a different text field.
Displaying the serials works fine by using "$D{production_order.SERIAL}" in a text field.

My SQL-statement of "production_order"
Code: [Select]
SELECT serial
FROM orders
WHERE orderId = $D{orders.id}

I want to display the amount of serial numbers without invoking a second SQL-statement with "Select count(*) ...".


I watched the video on limereport.ru and and adjusted my command to the syntax shown in the video.
Code: [Select]
$S{COUNT("$D{production_order.SERIAL}","DataBand1")}But I get:
Code: [Select]
SyntaxError: Parse errorI tried a lot and tested to omit some of the quotation marks as I seen it in some other forum posts. I also tried different DataBands, but it did not help. If I omit the quotation marks completely:
Code: [Select]
$S{COUNT($D{production_order.SERIAL},DataBand1)}I get:
Code: [Select]
Function COUNT not found or have wrong arguments

What am I doing wrong? Or is there another way to achieve my goal, maybe by using custom scripts/functions?
I am using version 1.4.49


Thanks in advance

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Syntax for group functions (COUNT, SUM, MIN, MAX, AVG)
« Reply #1 on: March 05, 2022, 12:31:43 am »
Hi!
Sorry for long waiting, I have not match free time.

Quote
What is the correct syntax?

The COUNT function must have the first argument in quotes and the second one without

Code: [Select]
$S{COUNT($D{orderitems.Quantity},"DataBand1")}

Quote
What is the purpose of the "DataBand"
in short - on which band the value is used