Showing posts with label perform. Show all posts
Showing posts with label perform. Show all posts

Wednesday, March 28, 2012

Query - pop-up menu for user data entry

Using the following syntax:
Select fname, lastn
From list
Where fname like 'jones'
I need the syntax that the user can enter a name to perform a query (the
user will enter a name on a pop-up menu before the query is performed).Roy,
You didn't say in what context you would be using this, so the below-code
assumes you are using a Stored Procedure:
CREATE STORED PROCEDURE [dbo].[usp_FindName]
@.LName varchar(100)=''
AS
IF @.LName<>''
BEGIN
Select fname, lastn
From list
Where fname like @.LName
END
GO
Hope thi assists,
Tony
"ROY A. DAY" wrote:

> Using the following syntax:
> Select fname, lastn
> From list
> Where fname like 'jones'
> I need the syntax that the user can enter a name to perform a query (the
> user will enter a name on a pop-up menu before the query is performed).

Wednesday, March 7, 2012

q; rounding up

X is a float and I need to perform x/20 and round the result up to the
integer. So if result is 0.4 -> 1, if 1.1 -> 2.
How can I do this with SQL?JIM.H. wrote:
> X is a float and I need to perform x/20 and round the result up to the
> integer. So if result is 0.4 -> 1, if 1.1 -> 2.
> How can I do this with SQL?
>
See CEILING in Books Online...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||select ceiling(0.4), ceiling(1.1)
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com

q; rounding up

X is a float and I need to perform x/20 and round the result up to the
integer. So if result is 0.4 -> 1, if 1.1 -> 2.
How can I do this with SQL?JIM.H. wrote:
> X is a float and I need to perform x/20 and round the result up to the
> integer. So if result is 0.4 -> 1, if 1.1 -> 2.
> How can I do this with SQL?
>
See CEILING in Books Online...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||select ceiling(0.4), ceiling(1.1)
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com

q; rounding up

X is a float and I need to perform x/20 and round the result up to the
integer. So if result is 0.4 -> 1, if 1.1 -> 2.
How can I do this with SQL?
JIM.H. wrote:
> X is a float and I need to perform x/20 and round the result up to the
> integer. So if result is 0.4 -> 1, if 1.1 -> 2.
> How can I do this with SQL?
>
See CEILING in Books Online...
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||select ceiling(0.4), ceiling(1.1)
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com

Saturday, February 25, 2012

q; how to write this

Hello,
I have MyTable with ID, IsYesNo fields
ID is duplicated so I need perform select on MyTable with the following
conditions:
1. Select all the ID distinct where IsYesNo=’Yes’ first
2. Then select all the ID distinct where IsYesNo=’No’ if ID is not in the
first selection
Combine these two and return the result
Try:
select distinct
ID
, IsYesNo
from
MyTable
where
IsYesNo = 'Yes'
union all
select distinct
ID
, IsYesNo
from
MyTable o
where
IsYesNo = 'No'
and not exists
(
select distinct
*
from
MyTable i
where
i.IsYesNo = 'Yes'
and
i.ID = o.ID
)
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
..
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:7E592B5E-81BB-420A-BDBE-9ED0C67689F4@.microsoft.com...
Hello,
I have MyTable with ID, IsYesNo fields
ID is duplicated so I need perform select on MyTable with the following
conditions:
1. Select all the ID distinct where IsYesNo=’Yes’ first
2. Then select all the ID distinct where IsYesNo=’No’ if ID is not in the
first selection
Combine these two and return the result
|||Looks like homework so ignoring the detail of the question but going straight
to the result
select ID, IsYesNo = max(IsYesNo)
from MyTable
Group by ID
"JIM.H." wrote:

> Hello,
> I have MyTable with ID, IsYesNo fields
> ID is duplicated so I need perform select on MyTable with the following
> conditions:
> 1. Select all the ID distinct where IsYesNo=’Yes’ first
> 2. Then select all the ID distinct where IsYesNo=’No’ if ID is not in the
> first selection
> Combine these two and return the result
>

q; how to write this

Hello,
I have MyTable with ID, IsYesNo fields
ID is duplicated so I need perform select on MyTable with the following
conditions:
1. Select all the ID distinct where IsYesNo=’Yes’ first
2. Then select all the ID distinct where IsYesNo=’No’ if ID is not in th
e
first selection
Combine these two and return the resultTry:
select distinct
ID
, IsYesNo
from
MyTable
where
IsYesNo = 'Yes'
union all
select distinct
ID
, IsYesNo
from
MyTable o
where
IsYesNo = 'No'
and not exists
(
select distinct
*
from
MyTable i
where
i.IsYesNo = 'Yes'
and
i.ID = o.ID
)
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
.
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:7E592B5E-81BB-420A-BDBE-9ED0C67689F4@.microsoft.com...
Hello,
I have MyTable with ID, IsYesNo fields
ID is duplicated so I need perform select on MyTable with the following
conditions:
1. Select all the ID distinct where IsYesNo=’Yes’ first
2. Then select all the ID distinct where IsYesNo=’No’ if ID is not in th
e
first selection
Combine these two and return the result|||Looks like homework so ignoring the detail of the question but going straigh
t
to the result
select ID, IsYesNo = max(IsYesNo)
from MyTable
Group by ID
"JIM.H." wrote:

> Hello,
> I have MyTable with ID, IsYesNo fields
> ID is duplicated so I need perform select on MyTable with the following
> conditions:
> 1. Select all the ID distinct where IsYesNo=’Yes’ first
> 2. Then select all the ID distinct where IsYesNo=’No’ if ID is not in
the
> first selection
> Combine these two and return the result
>

q; how to write this

Hello,
I have MyTable with ID, IsYesNo fields
ID is duplicated so I need perform select on MyTable with the following
conditions:
1. Select all the ID distinct where IsYesNo=â'Yesâ' first
2. Then select all the ID distinct where IsYesNo=â'Noâ' if ID is not in the
first selection
Combine these two and return the resultTry:
select distinct
ID
, IsYesNo
from
MyTable
where
IsYesNo = 'Yes'
union all
select distinct
ID
, IsYesNo
from
MyTable o
where
IsYesNo = 'No'
and not exists
(
select distinct
*
from
MyTable i
where
i.IsYesNo = 'Yes'
and
i.ID = o.ID
)
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
.
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:7E592B5E-81BB-420A-BDBE-9ED0C67689F4@.microsoft.com...
Hello,
I have MyTable with ID, IsYesNo fields
ID is duplicated so I need perform select on MyTable with the following
conditions:
1. Select all the ID distinct where IsYesNo=â'Yesâ' first
2. Then select all the ID distinct where IsYesNo=â'Noâ' if ID is not in the
first selection
Combine these two and return the result|||Looks like homework so ignoring the detail of the question but going straight
to the result
select ID, IsYesNo = max(IsYesNo)
from MyTable
Group by ID
"JIM.H." wrote:
> Hello,
> I have MyTable with ID, IsYesNo fields
> ID is duplicated so I need perform select on MyTable with the following
> conditions:
> 1. Select all the ID distinct where IsYesNo=â'Yesâ' first
> 2. Then select all the ID distinct where IsYesNo=â'Noâ' if ID is not in the
> first selection
> Combine these two and return the result
>