Help. Two Unknown Values in Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pcwaleed
    New Member
    • Mar 2014
    • 3

    Help. Two Unknown Values in Query

    Hi every body:
    I have program store which appeared the new salary to the unit out
    The problem is: 2 values unknown (out_salary,out _amount)
    The table(info) contain 8 fields (id,code_store, code_unit,date_ rec,in_quantity ,in_s alary,in_amount ,out_quantity)
    The quiry must give me the following result:
    [id]
    [code_store]
    [code_unit]
    [date_rec]
    [In_quantity]
    [in_salary]
    [in_amount]
    [out_quantity]
    [out_salary] "take from [new_salary]
    [out_amount] = [out_quantity]*[out_salary]
    [sum_quantity] "accumulati ve summation" (In_quantity]- [out_quantity])
    [sum_amount]" "accumulati ve summation" ([in_amount]- [out_amount])
    [New_salary] =([In_quantity]- [out_quantity])/ ([in_amount]- [out_amount])

    At last the report appeared as this
    Attached Files
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    You need to create those fields, they are not already in your data. So you cannot just reference them, you need to create them. Your SQL code for the query should contain something like this:
    Code:
    [new_salary] AS out_salary,[out_quantity]*[in_salary] as [out_amount]
    If you're using the query editor (GUI) you'll have columns like this:
    out_amount:[new_salary]*[out_quantity]
    out_salary:[new_salary]

    Where a new field is simply a copy of an old field, you just need to select it and rename with the AS directive. In the editor you simply add a label, a colon and then the name of the old field.

    Jim
    Last edited by jimatqsi; Mar 4 '14, 01:03 PM. Reason: add tags, finish post

    Comment

    • pcwaleed
      New Member
      • Mar 2014
      • 3

      #3
      hello mr.jim
      I need the query this :
      Code:
      [new_salary] AS out_salary,[out_quantity]*[out
      _salary] as [out_amount]
      but based on this query happend error because the value of new_salary is taking from
      Code:
      ([In_quantity]- [out_quantity])/ ([in_amount]- [out_amount]
      one unknown value is depend on unknown value
      if you have the slove can you apply on my database please
      thank you

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        But out_salary is just another name for new_salary. If you simply change
        [out_quantity]*[out_salary]
        to
        [out_quantity]*[new_salary]
        the problem goes away.

        Jim

        Comment

        • pcwaleed
          New Member
          • Mar 2014
          • 3

          #5
          no problem Mr.Jim
          [out_salary] =[new_salary]
          what is the benefit from this
          can you explain to me please

          Comment

          Working...