New questions

(2 posts) (2 voices)

Tags:

No tags yet.

  1. Bhavin Shah, Member

    Hi,

    Thanks for the reply on my previous thread. I have few more questions.

    1. When using pagination for some reason, sorting disappears and also try to sort the data in query does not work.

    2. Suppose I have drop down based on which I would like to show reports. Drop down values are nothing but column names based on which i need to sum(column_name) in select query. When I do declare and set the variable with column name and passed it in query it does not work.

    Sniffet of the code is

    DECLARE vcolumn VARCHAR(100)
    IF t = 'Revenue' THEN
    vcolumn = 'revenue';
    END IF;

    select items,sum(vcolumn) as earnings from my_table group by items;

    This always throws 0 revenue. If I remove single quotes, then it says revenue column does not exists.

    Thanks in advance for your response.

  2. myDBR Team, Key Master

    The pagination does remove the client side sorting. You can however sort the data in your query.

    As for the dynamic content, the variable vcolumn without quotes refers to the variable (sum('Revenue')) and without quotes it would refer to a column named vcolumn.

    To make the sum-column dynamic, you can either use CASE WHEN syntax, or calculate possible sum columns and hide the ones you wish not to show.

    --
    myDBR Team


Reply

You must log in to post.