KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Academy Nearly same query but different result.

Tagged: 

  • Nearly same query but different result.

    Posted by Aditya on March 30, 2025 at 3:56 pm

    Hey
    these two query should be providing same output. Please help me understand why they are different.

    select trips : count i by date from jan09 lj `date xkey select date, avgtemp from weather</p><p>jan09C:select trips: count i by date from jan09</p><p>jan09C lj `date xkey select date, avgtemp from weather

    Aditya replied 14 hours, 56 minutes ago 2 Members · 2 Replies
  • 2 Replies
  • abstrphil

    Member
    March 31, 2025 at 5:34 am

    q interprets right-to-left, so what your first expression is actually doing is executing the lj on jan09 before selecting from it.

    What it’s therefore doing is counting the number of rows from the combined table.

    The second expression is selecting the table *then* executing the join, which is why you now see the avgTemps.

  • Aditya

    Member
    April 1, 2025 at 5:39 pm

    Thanks a lot
    this makes sense

Log in to reply.