Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #606

Help with Query

From FCB <dave.white19@gmail.com>
Newsgroups comp.databases.ms-sqlserver
Subject Help with Query
Date 2011-08-19 13:51 -0700
Organization http://groups.google.com
Message-ID <9cb19b3e-a83f-4860-84d3-a82f12eadff7@b9g2000prd.googlegroups.com> (permalink)

Show all headers | View raw


Have written basic queries with SQL for a while now but have been
given a project that requires me to step it up a notch. Any help would
be appreciated.

I have a table that lists customer records; one row per customer but
there can be more than one customer per account.

For example

Account     Customer      First      Last                 Status
1               1                  James   Joyce
Active
1               2                  Nora      Barnacle          Active
2               1                  Fred      Flintstone         Active
3               1                  Barney  Rubble
Inactive
3               2                  Betty     Rubble             Active

I'm trying to create a query that will choose the first active
customer only. Is there a way to use the min() function to loop
through each account number and choose the lowest customer per
account? Or is there another function that can be used.

Thanks again,

Dave


Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

Help with Query FCB <dave.white19@gmail.com> - 2011-08-19 13:51 -0700
  Re: Help with Query Erland Sommarskog <esquel@sommarskog.se> - 2011-08-19 23:52 +0200
    Re: Help with Query FCB <dave.white19@gmail.com> - 2011-08-20 09:19 -0700

csiph-web