Viewing 15 posts - 811 through 825 (of 1,132 total)
Based on your post:
1. For each email address, get a count of unique usernames.
SQL:
select email, count(distinct username)
from dup_emails
group by email
Result:
2. For each username, check to see that it...
December 3, 2005 at 6:40 am
In the future. please provide DDL and sample data as per http://www.aspfaq.com/etiquette.asp?id=5006
Renaming the temporary table to a alias that does not begin with the @ symbol seems to solve...
December 3, 2005 at 6:02 am
Is there some reason for making the solution to such a simple problem so complicated ?
You can use the CASE statement or a two line UDF.
alter FUNCTION dbo.udf_IsShiftValid
(@StartTime datetime
, @EndTime...
December 2, 2005 at 3:28 pm
The "self-blocking" condition will also appear after installing SQL Server Service Pack 4.
See "The blocked column in the sysprocesses table is populated for latch waits after you install SQL Server...
December 2, 2005 at 9:33 am
Hey Jeff:
I think we have all had to deal with Clients who have decided to impose an architecture where not all ramifications have been considered.
When you present a solution...
December 1, 2005 at 3:54 pm
Is there some reason that you are using non-standard SQL such as ISNULL instead of COALESCE and CONVERT instead of CAST ?
The SQL originally posted will run unchanged under DB2,...
November 30, 2005 at 4:13 pm
Below is a really stupid solution but it does work under your restrictions.
Use your existing Dynamic SQL solution to generate a stored procedure for every possible combination of the bitmask....
November 30, 2005 at 11:47 am
Please provide DDL and sample data. See http://www.aspfaq.com/etiquette.asp?id=5006 for instructions.
Here is an untested solution:
select MyTable.Product_Number
, MyTable.Qty_low
, COALESCE( MIN (H.Qty_low) - 1 , 999999999) from MyTable
Left outer join
MyTable as H
on H.Product_Number...
November 29, 2005 at 5:43 pm
Good catch of the bad algorithm and the elegant solution.
November 29, 2005 at 4:15 pm
In the future, please post create table and insert statements.
How about this SQL (an index on Users.email is recommended)
select email, product_id, product_status
, MIN (username)
Into GoodUsers
FROM ( SELECT email, product_id
,...
November 29, 2005 at 3:56 pm
select Year(DateSubmitted) as SubmittedYear
, DATENAME ( mm , DateSubmitted ) as SubmittedMonth
, count(*) as ApplCount
from Applications
where DateSubmitted between @MonthStartDate and @MonthEndDate
group by Year(DateSubmitted)
, Month(DateSubmitted)
, DATENAME (...
November 29, 2005 at 6:57 am
The calculation is relatively simple:
Take the day of the month for the date and divide by seven (as this is integer calculations, truncation will occur) to get the number of...
November 28, 2005 at 7:02 pm
Try:
select country.country AS [Country],
orders.ref_number AS [Ref #],
orders.open_date AS [Date],
orders.Description AS [Description]
, COUNT(*) -- NEW
FROM orders
left join users orders.userid = users.id
left join country users.countryid = country.id
-- NEW START
GROUP BY country.country...
November 28, 2005 at 6:17 pm
Regarding, "You missed the case when 2 or more shareholders are the largest", should not this section of the SQL handle that case?
select ContractParty.ContractId
, MIN(PartyId) AS PartyId
from ContractParty
join (select ContractParty.ContractId
,...
November 28, 2005 at 5:51 pm
Here is a set-based method based to assign the rounding amount to the party with the largest share and if two parties have equal shares, then the one with the...
November 28, 2005 at 1:13 pm
Viewing 15 posts - 811 through 825 (of 1,132 total)