pass a value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alexqa2003@yahoo.com

    #1

    pass a value

    is it possible to do:
    (A)
    declare @numberofitems Int
    @numberofitems = select max(itemorder)
    from store, department, etc.

    and pass the @numberofitems to a #tempStore table, like:
    (B)
    (store, department, @numberofitems, ...)

    I got itemorder but not the number of items in each department
    Alex




    --
    Sent by 3 from yahoo part from com
    This is a spam protected message. Please answer with reference header.
    Posted via http://www.usenet-replayer.com/cgi/content/new
  • John Bell

    #2
    Re: pass a value

    Hi

    You don;t give enough detail to produce an exact query. Please post DDL,
    example data (as insert statements) and expected output if you require a
    more precise answer.

    At a guess something like:

    SELECT S.Store, D.Department, max(I.itemorder ) as NumberOfItems
    from store S JOIN department D ON S.StoreId = D.StoreId
    JOIN ItemsOrders I On I.DeptId = D.DeptId
    GROUP BY S.Store, D.Department

    or

    SELECT S.Store, D.Department, ( SELECT max(I.itemorder ) FROM ItemsOrders I
    WHERE I.DeptId = D.DeptId AND S.StoreId = I.StoreId ) as NumberOfItems
    FROM store S JOIN department D ON S.StoreId = D.StoreId

    John

    etc"alexqa2003@ yahoo.com" <u128845214@spa wnkill.ip-mobilphone.net> wrote in
    message news:l.10624712 42.1626678466@h ost-66-81-78-52.rev.o1.com.. .[color=blue]
    > is it possible to do:
    > (A)
    > declare @numberofitems Int
    > @numberofitems = select max(itemorder)
    > from store, department, etc.
    >
    > and pass the @numberofitems to a #tempStore table, like:
    > (B)
    > (store, department, @numberofitems, ...)
    >
    > I got itemorder but not the number of items in each department
    > Alex
    >
    >
    >
    >
    > --
    > Sent by 3 from yahoo part from com
    > This is a spam protected message. Please answer with reference header.
    > Posted via http://www.usenet-replayer.com/cgi/content/new[/color]



    Comment

    • Simon Hayes

      #3
      Re: pass a value

      u128845214@spaw nkill.ip-mobilphone.net (alexqa2003@yah oo.com) wrote in message news:<l.1062471 242.1626678466@ host-66-81-78-52.rev.o1.com>. ..[color=blue]
      > is it possible to do:
      > (A)
      > declare @numberofitems Int
      > @numberofitems = select max(itemorder)
      > from store, department, etc.
      >
      > and pass the @numberofitems to a #tempStore table, like:
      > (B)
      > (store, department, @numberofitems, ...)
      >
      > I got itemorder but not the number of items in each department
      > Alex[/color]

      It's not really clear from your post what you're trying to do, but it
      may be something like this:

      insert into #tempStore
      (store, department, numberofitems)
      select store, department, max(itemorder)
      from orders
      group by store, department

      Or maybe this:

      insert into #tempStore
      (store, department, numberofitems)
      select store, department, count(itemorder )
      from orders
      group by store, department

      If this doesn't help, then it would be good if you can post your DDL
      (CREATE TABLE statements), along with some sample data and the
      expected output.

      Simon

      Comment

      Working...