|
|
 |
 |
 |
 |
Need help with the SELECT statement please.
Hi all, I am try to write a query and get the result show below but get stock. Any help would greatly appreciate. drop table #temp go CREATE TABLE #temp ( Agent_nb INT NULL, LastName VARCHAR(15) NULL, FirstName VARCHAR(15) NULL, Auto_nb INT NULL, ClueOrder INT NULL ) go INSERT #temp VALUES (1977, 'Chan', 'Wendy', 25, 5) INSERT #temp VALUES (2803, 'Leslie', 'Kenneth', 23, 3) INSERT #temp VALUES (3080, 'Anderson', 'Melisa', 0, 0) INSERT #temp VALUES (5411, 'Langford', 'Jonlyn', 0, 1) INSERT #temp VALUES (6600, 'Jolly', 'Christopher', 1, 0) go SELECT * FROM #temp go -- Business Rules: Exclude all records with Auto_nb = 0 and ClueOrder = 0. Result want: Agent_nb LastName FirstName Auto_nb ClueOrder ----------- --------------- --------------- ----------- ----------- 1977 Chan Wendy 25 5 2803 Leslie Kenneth 23 3 5411 Langford Jonlyn 0 1 6600 Jolly Christopher 1 0 SELECT * FROM #temp go
SELECT * FROM #temp WHERE NOT (Auto_nb = 0 AND ClueOrder = 0) "Lam Nguyen" <LamNgu @discussions.microsoft.com> wrote in message news:0118367C-255E-4FE1-B19C-7B94F06031BE@microsoft.com...
> Hi all, > I am try to write a query and get the result show below but get stock. > Any > help would greatly appreciate. > drop table #temp > go > CREATE TABLE #temp > ( > Agent_nb INT NULL, > LastName VARCHAR(15) NULL, > FirstName VARCHAR(15) NULL, > Auto_nb INT NULL, > ClueOrder INT NULL > ) > go > INSERT #temp VALUES (1977, 'Chan', 'Wendy', 25, 5) > INSERT #temp VALUES (2803, 'Leslie', 'Kenneth', 23, 3) > INSERT #temp VALUES (3080, 'Anderson', 'Melisa', 0, 0) > INSERT #temp VALUES (5411, 'Langford', 'Jonlyn', 0, 1) > INSERT #temp VALUES (6600, 'Jolly', 'Christopher', 1, 0) > go > SELECT * > FROM #temp > go > -- Business Rules: Exclude all records with Auto_nb = 0 and ClueOrder = > 0. > Result want: > Agent_nb LastName FirstName Auto_nb ClueOrder > ----------- --------------- --------------- ----------- ----------- > 1977 Chan Wendy 25 5 > 2803 Leslie Kenneth 23 3 > 5411 Langford Jonlyn 0 1 > 6600 Jolly Christopher 1 0 > SELECT * > FROM #temp > go
Hi all, I am try to write a query and get the result show below but get stock. Any help would greatly appreciate. drop table #temp go CREATE TABLE #temp ( Agent_nb INT NULL, LastName VARCHAR(15) NULL, FirstName VARCHAR(15) NULL, Auto_nb INT NULL, ClueOrder INT NULL ) go INSERT #temp VALUES (1977, 'Chan', 'Wendy', 25, 5) INSERT #temp VALUES (2803, 'Leslie', 'Kenneth', 23, 3) INSERT #temp VALUES (3080, 'Anderson', 'Melisa', 0, 0) INSERT #temp VALUES (5411, 'Langford', 'Jonlyn', 0, 1) INSERT #temp VALUES (6600, 'Jolly', 'Christopher', 1, 0) go SELECT * FROM #temp go -- Business Rules: Exclude all records with Auto_nb = 0 and ClueOrder = 0. Result want: Agent_nb LastName FirstName Auto_nb ClueOrder ----------- --------------- --------------- ----------- ----------- 1977 Chan Wendy 25 5 2803 Leslie Kenneth 23 3 5411 Langford Jonlyn 0 1 6600 Jolly Christopher 1 0 SELECT * FROM #temp go
-----------------------------------------------Reply-----------------------------------------------
Hi all, I am try to write a query and get the result show below but get stock. Any help would greatly appreciate. drop table #temp go CREATE TABLE #temp ( Agent_nb INT NULL, LastName VARCHAR(15) NULL, FirstName VARCHAR(15) NULL, Auto_nb INT NULL, ClueOrder INT NULL ) go INSERT #temp VALUES (1977, 'Chan', 'Wendy', 25, 5) INSERT #temp VALUES (2803, 'Leslie', 'Kenneth', 23, 3) INSERT #temp VALUES (3080, 'Anderson', 'Melisa', 0, 0) INSERT #temp VALUES (5411, 'Langford', 'Jonlyn', 0, 1) INSERT #temp VALUES (6600, 'Jolly', 'Christopher', 1, 0) go SELECT * FROM #temp go -- Business Rules: Exclude all records with Auto_nb = 0 and ClueOrder = 0. Result want: Agent_nb LastName FirstName Auto_nb ClueOrder ----------- --------------- --------------- ----------- ----------- 1977 Chan Wendy 25 5 2803 Leslie Kenneth 23 3 5411 Langford Jonlyn 0 1 6600 Jolly Christopher 1 0 SELECT * FROM #temp go
-----------------------------------------------Reply-----------------------------------------------
SELECT * FROM #temp WHERE (Auto_nb <> 0 OR ClueOrder <> 0) Roy Harvey Beacon Falls, CT On Wed, 6 Jun 2007 13:14:05 -0700, Lam Nguyen
<LamNgu @discussions.microsoft.com> wrote: >Hi all, >I am try to write a query and get the result show below but get stock. Any >help would greatly appreciate. >drop table #temp >go >CREATE TABLE #temp >( > Agent_nb INT NULL, > LastName VARCHAR(15) NULL, > FirstName VARCHAR(15) NULL, > Auto_nb INT NULL, > ClueOrder INT NULL >) >go >INSERT #temp VALUES (1977, 'Chan', 'Wendy', 25, 5) >INSERT #temp VALUES (2803, 'Leslie', 'Kenneth', 23, 3) >INSERT #temp VALUES (3080, 'Anderson', 'Melisa', 0, 0) >INSERT #temp VALUES (5411, 'Langford', 'Jonlyn', 0, 1) >INSERT #temp VALUES (6600, 'Jolly', 'Christopher', 1, 0) >go >SELECT * > FROM #temp >go >-- Business Rules: Exclude all records with Auto_nb = 0 and ClueOrder = 0. >Result want: >Agent_nb LastName FirstName Auto_nb ClueOrder >----------- --------------- --------------- ----------- ----------- >1977 Chan Wendy 25 5 >2803 Leslie Kenneth 23 3 >5411 Langford Jonlyn 0 1 >6600 Jolly Christopher 1 0 > SELECT * > FROM #temp > go
|
 |
 |
 |
 |
|