CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: SQL

  1. #1
    Join Date
    Jul 1999
    Posts
    20

    SQL


    Dear friend, I always get this message

    ---------------------------------------------------------------------------
    You tried to execute a querry that doesn't include the specified expression 'FORMAT(Start_Date, "ttttt")' as part of an aggregate function.
    ---------------------------------------------------------------------------
    Can anyone explain to me why I always get this message when I tried to get some information from the SQL server. my code is as below:


    {"SELECT FORMAT(Start_Date, "yyyy"), FORMAT(Start_Date, "mm"), FORMAT(Start_Date, "ttttt"), FORMAT(Start_Date, "Short Date"), FORMAT(Start_Date, "ww") AS Week"}

    {", SUM(Qty_IN) AS [Total Qty IN], Sum(Qty_OUT) AS [Total Qty OUT], Sum(ASSIST) AS [Total Assists], Sum(FAIL) AS [Total Failure], Sum(Lapsed_Time) AS [Total Lapsed Time]"}

    {" FROM [;database=D:\iCONext\LOG\1998-06.mdb].LogPerformance"}

    {" WHERE FORMAT(Start_Date, "yyyy") BETWEEN 1998 AND 1998 AND FORMAT(Start_Date, "ww") BETWEEN 24 AND 24"}

    {" GROUP BY FORMAT(Start_Date, "yyyy"), FORMAT(Start_Date, "mm"), FORMAT(Start_Date, "ww")"}

    {" ORDER BY FORMAT(Start_Date, "yyyy")+FORMAT(Start_Date, "mm")+FORMAT(Start_Date, "ttttt")"}




    Thanks


  2. #2
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    51

    Re: SQL

    I'm confused...

    1.) Where is the FORMAT(...) coming from C++ or SQL???? Let me know and I will try to help more!

    2.) Your Statement:

    FORMAT(Start_Date, "yyyy") BETWEEN 1998 AND 1998 AND FORMAT(Start_Date, "ww") BETWEEN 24 AND 24

    BETWEEN (in BOTH places) is NOT needed...just say:

    FORMAT(Start_Date, "yyyy") = 1998 AND FORMAT(Start_Date, "ww") = 24

    3.) Since I've looked in SQL Books Online & VC++ and can't find this FORMAT??? The following is a guess:

    FORMAT(Start_Date, "ttttt") ...... Possibly use only 4 t's and not 5.


    Thanks in advance,

    Dan
    Thanks,
    Dan

    Old Programmers never die, they just program away...

  3. #3
    Guest

    Re: SQL

    You are trying to FORMAT the information contained in the column Start_Date in 5 different ways?

    What exactly are you trying to accomplish?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured