Results 1 to 8 of 8

Thread: Query Issue

  1. #1
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,434

    Question Query Issue

    The following inner querey return 9/9/2012 7:45:21 AM .
    so simple i want all the records from OracleTradingSummaryDetail .which is matching with
    SELECT Max(TradingSummaryStatus.UPDATEDTIME

    but when i running the following query it is asking UpdatedTime as a parameter .why ? it needs to show all the matching rows .
    Code:
    SELECT *
    FROM OracleTradingSummaryDetail
    WHERE UPDATEDTIME=
    (SELECT Max(TradingSummaryStatus.UPDATEDTIME) as LastSalesDate
    FROM TradingSummaryStatus
    WHERE Status<>'C');
    Last edited by firoz.raj; Sep 19th, 2012 at 12:34 PM.

  2. #2
    Hirsute Mumbler FunkyDexter's Avatar
    Join Date
    Apr 05
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    2,437

    Re: Query Issue

    I'm guessing this is Access. If so then Access doesn't recognise the field UpdatedTime on the OracleTradingSummaryDetail table so it think's you're referenceing a parameter. Check the spelling of all the field and table names you've used in the query.
    When one of my minions says, "Hey, he's just one guy, what can he do?" I say "This"... and shoot them.

    The problem with putting your lair in a volcano is keeping your robot army from melting.

    I know that the human being and the fish can coexist peacefully - George Bush

  3. #3
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,434

    Re: Query Issue

    speeling is correct .I Modified a bit . because i need WeekNo,Status ... of Trading summary Status table .
    but it does not show anything .which status is not c .means not close.
    Code:
    SELECT TradingSummaryStatus.YEAR, TradingSummaryStatus.WEEKNO, TradingSummaryStatus.UPDATEDTIME, TradingSummaryStatus.STATUS, *
    FROM OracleTradingSummaryDetail INNER JOIN TradingSummaryStatus ON OracleTradingSummaryDetail.ID = TradingSummaryStatus.ID
    WHERE (((TradingSummaryStatus.UPDATEDTIME)=(SELECT Max(TradingSummaryStatus.UPDATEDTIME) as LastSalesDate FROM TradingSummaryStatus WHERE Status<>'C')));

  4. #4
    Hirsute Mumbler FunkyDexter's Avatar
    Join Date
    Apr 05
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    2,437

    Re: Query Issue

    Is it still asking for UpdatedTime as a parameter or is it just not returning data?
    And can you confirm that this is an Access database?

    Also, it helps us see what's going on if you lay your sql out in a nice freindly way. The way you laid it out in the first post was perfect.
    When one of my minions says, "Hey, he's just one guy, what can he do?" I say "This"... and shoot them.

    The problem with putting your lair in a volcano is keeping your robot army from melting.

    I know that the human being and the fish can coexist peacefully - George Bush

  5. #5
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,434

    Re: Query Issue

    And can you confirm that this is an Access database?
    Yes it is again asking updated Time . oh yes i am using Ms Access Database .

  6. #6
    Hirsute Mumbler FunkyDexter's Avatar
    Join Date
    Apr 05
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    2,437

    Re: Query Issue

    Access assumes anything it doesn't recognise is a paramater. If it's asking for UpdatedTime then one of the references to UpdatedTime in your query is incorrect. In the query you posted last you reference UpdatedTime 3 times and every time it's from the TradingSummaryStatus table. That leaves 3 possibilities:-
    1. There is no UpdatedTime field on the TradingSummaryStatus table
    2. The field name is miss-spelt
    3. You're not running the sql you've posted here.
    When one of my minions says, "Hey, he's just one guy, what can he do?" I say "This"... and shoot them.

    The problem with putting your lair in a volcano is keeping your robot army from melting.

    I know that the human being and the fish can coexist peacefully - George Bush

  7. #7
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,434

    Re: Query Issue

    i want to insert the saleslevel1 as it is in a tradingsummary staus table for csaleslevel . as it is string datatype . but i am still getting error at red line .let me know please as sales level is string so i put in inverted comma. but still i am getting error . let me know please .
    Code:
    con.Execute "insert into tradingsummarystatus(BRANDID,BRANDDETAIL,GROUP_NO,WEEKNO,years,CSALESLEVEL) select brandid,brandDetail,groupno," & Val(CmbWeekNo.Text) & ",2012, "Saleslevel1" from brandmaster"

  8. #8
    Member
    Join Date
    Oct 12
    Posts
    37

    Re: Query Issue

    It is better if you use variables for better readability!
    The Correct syntax is:
    dim strsql as string
    strsql="insert into tradingsummarystatus(BRANDID,BRANDDETAIL,GROUP_NO,WEEKNO,years,CSALESLEVEL) Values(brandid,brandDetail,groupno," & Val(CmbWeekNo.Text) & ",2012, '" & salesLevel1 & "'"
    con.Execute strsql

    You cannot get saleslevel1 from brandmaster table while executing this command. Instead get it before in the string saleslevel1 and then execute it.
    You are assuming WEEKNO and YEARS as numeric fields, isn't it?
    I am in the process of uploading my supermarket project at download.cnet.com I will confirm that as soon as I do it.

Posting Permissions

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