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. Database & SysAdmin
  3. Database
  4. Table Variable result set ???

Table Variable result set ???

Scheduled Pinned Locked Moved Database
databasequestion
3 Posts 3 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.
  • T Offline
    T Offline
    tthellebuyck
    wrote on last edited by
    #1

    I have filled a table variable with some invoice data and it looks like this: Invoice# Batch# 733F7F75 946 733F7F75 924 733F7F75 929 733F7F75 940 733F7F75 948 733F7F75 939 733F7F75 947 733F7F75 923 733F7F75 938 733F7F75 922 733F7F75 927 733F7F75 944 733F7F75 945 I have a basic select query on that temp table, something like this: select InvoiceNumber, BatchNumber from @t order by InvoiceNumber what can I do to get the highest batchNumber (Underlined result up there ^) from my table variable?

    D J 2 Replies Last reply
    0
    • T tthellebuyck

      I have filled a table variable with some invoice data and it looks like this: Invoice# Batch# 733F7F75 946 733F7F75 924 733F7F75 929 733F7F75 940 733F7F75 948 733F7F75 939 733F7F75 947 733F7F75 923 733F7F75 938 733F7F75 922 733F7F75 927 733F7F75 944 733F7F75 945 I have a basic select query on that temp table, something like this: select InvoiceNumber, BatchNumber from @t order by InvoiceNumber what can I do to get the highest batchNumber (Underlined result up there ^) from my table variable?

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      How about using max function?

      Avoid Google. Use Blackle[^]

      1 Reply Last reply
      0
      • T tthellebuyck

        I have filled a table variable with some invoice data and it looks like this: Invoice# Batch# 733F7F75 946 733F7F75 924 733F7F75 929 733F7F75 940 733F7F75 948 733F7F75 939 733F7F75 947 733F7F75 923 733F7F75 938 733F7F75 922 733F7F75 927 733F7F75 944 733F7F75 945 I have a basic select query on that temp table, something like this: select InvoiceNumber, BatchNumber from @t order by InvoiceNumber what can I do to get the highest batchNumber (Underlined result up there ^) from my table variable?

        J Offline
        J Offline
        John Ad
        wrote on last edited by
        #3

        Hi, Use Max function to get the largest number from the table. The syntax is: SELECT MAX(net_amount) FROM Sales; SELECT MAX(company) FROM Sales WHERE net_amount > 100; I hope this would be helpful.

        Vinay ComponentOne LLC. www.componentone.com

        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