Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. sql inquiry

sql inquiry

Scheduled Pinned Locked Moved Visual Basic
databasequestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maytel
    wrote on last edited by
    #1

    i have 2 tables A and B is it possible in sql to get from B the last occurence (based on date) for each record in A? ex A cust1 cust2 B cust1 01012006 10.00 cust1 01022006 20.00 cust2 01022006 30.00 cust2 01032006 40.00 output cust1 01022006 20.00 cust2 01032006 40.00 tnx in advance maytel

    M V 2 Replies Last reply
    0
    • M maytel

      i have 2 tables A and B is it possible in sql to get from B the last occurence (based on date) for each record in A? ex A cust1 cust2 B cust1 01012006 10.00 cust1 01022006 20.00 cust2 01022006 30.00 cust2 01032006 40.00 output cust1 01022006 20.00 cust2 01032006 40.00 tnx in advance maytel

      M Offline
      M Offline
      Mahbub8957
      wrote on last edited by
      #2

      Please check is it work or not: Select custID, Max(date field) from B group by custID Where custID in (Select Distinct custID from A) Mahbub8957

      1 Reply Last reply
      0
      • M maytel

        i have 2 tables A and B is it possible in sql to get from B the last occurence (based on date) for each record in A? ex A cust1 cust2 B cust1 01012006 10.00 cust1 01022006 20.00 cust2 01022006 30.00 cust2 01032006 40.00 output cust1 01022006 20.00 cust2 01032006 40.00 tnx in advance maytel

        V Offline
        V Offline
        ver082874
        wrote on last edited by
        #3

        i forgot one detail let me rephrase is it possible in sql to get data from B (based on date SPECIFIED by the user) for each record in A? date specified by user 01012006 A cust1 cust2 B cust1 01/01/2006 10.00 cust1 01/02/2006 20.00 cust2 12/31/2005 30.00 cust2 01/03/2006 40.00 output cust1 01/01/2006 10.00 cust2 12/31/2005 30.00

        M G 2 Replies Last reply
        0
        • V ver082874

          i forgot one detail let me rephrase is it possible in sql to get data from B (based on date SPECIFIED by the user) for each record in A? date specified by user 01012006 A cust1 cust2 B cust1 01/01/2006 10.00 cust1 01/02/2006 20.00 cust2 12/31/2005 30.00 cust2 01/03/2006 40.00 output cust1 01/01/2006 10.00 cust2 12/31/2005 30.00

          M Offline
          M Offline
          Matthew Hazlett
          wrote on last edited by
          #4

          Your question is not very clear, but I think you want somthing like this: select b.* from b, a where a.user = b.user and b.date = '01/01/05'; Matthew Hazlett

          1 Reply Last reply
          0
          • V ver082874

            i forgot one detail let me rephrase is it possible in sql to get data from B (based on date SPECIFIED by the user) for each record in A? date specified by user 01012006 A cust1 cust2 B cust1 01/01/2006 10.00 cust1 01/02/2006 20.00 cust2 12/31/2005 30.00 cust2 01/03/2006 40.00 output cust1 01/01/2006 10.00 cust2 12/31/2005 30.00

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Join in the B table and filter out the dates after the specified date. Group by the fields in the A table and use max() to get the latest date from the B table. --- b { font-weight: normal; }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups