sql command error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • avi25b
    New Member
    • Feb 2008
    • 2

    sql command error

    Respected Sir,

    I run once sql querry in sql 2000 but show error. pls give me soluction now.

    SELECT a.BILL_DATE,
    COUNT (DISTINCT a.bill_number + ' ' + a.bill_date + ' ' + a.till_number) nob,
    SUM (a.net_amt) bill_value
    FROM bill_detail b, bill_header a
    WHERE b.bill_date='10-feb-08'
    AND a.bill_date = b.bill_date
    AND a.bill_number = b.bill_number
    AND a.till_number = b.till_number
    AND a.bill_status = 'B'
    --AND b.net_amt > 199
    GROUP BY a.bill_date

    show error--------------------

    Server: Msg 8114, Level 16, State 5, Line 1
    Error converting data type varchar to numeric.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    The error message is self explanatory.

    Comment

    • avi25b
      New Member
      • Feb 2008
      • 2

      #3
      How Run Above Querry In Sql Server 2000

      SELECT TO_CHAR (&start_date, 'DD MON')
      || ' TO '
      || TO_CHAR (&end_date, 'DD MON YY') AS BILL_DATE,
      COUNT (DISTINCT a.bill_number || a.bill_date || a.till_number) nob,
      SUM (a.net_amt) bill_value
      FROM bill_detail a, bill_header b
      WHERE b.bill_date BETWEEN &START_DATE AND &END_DATE
      AND a.bill_date = b.bill_date
      AND a.bill_number = b.bill_number
      AND a.till_number = b.till_number
      AND b.bill_status = 'B'
      --AND b.net_amt > 199
      GROUP BY b.bill_date

      HOW RUN ABOVE QUERRY IN SQL SERVER 2000
      Last edited by avi25b; Feb 12 '08, 06:53 AM. Reason: NOT CORRECT QUERRY

      Comment

      • deepuv04
        Recognized Expert New Member
        • Nov 2007
        • 227

        #4
        Originally posted by avi25b
        SELECT TO_CHAR (&start_date, 'DD MON')
        || ' TO '
        || TO_CHAR (&end_date, 'DD MON YY') AS BILL_DATE,
        COUNT (DISTINCT a.bill_number || a.bill_date || a.till_number) nob,
        SUM (a.net_amt) bill_value
        FROM bill_detail a, bill_header b
        WHERE b.bill_date BETWEEN &START_DATE AND &END_DATE
        AND a.bill_date = b.bill_date
        AND a.bill_number = b.bill_number
        AND a.till_number = b.till_number
        AND b.bill_status = 'B'
        --AND b.net_amt > 199
        GROUP BY b.bill_date

        HOW RUN ABOVE QUERRY IN SQL SERVER 2000
        try the following query

        SELECT convert(varchar (15),@start_dat e, 106)
        + ' TO '
        + convert(varchar (15),@end_date, 106) AS BILL_DATE,
        COUNT (DISTINCT a.bill_number || a.bill_date || a.till_number) nob,
        SUM (a.net_amt) bill_value
        FROM bill_detail a, bill_header b
        WHERE b.bill_date BETWEEN @start_date AND @end_date
        AND a.bill_date = b.bill_date
        AND a.bill_number = b.bill_number
        AND a.till_number = b.till_number
        AND b.bill_status = 'B'
        --AND b.net_amt > 199
        GROUP BY b.bill_date

        thnks

        Comment

        Working...