Viewing 15 posts - 91 through 105 (of 414 total)
How about the following:
select sum(case when price >= 20 then price*1.15 when price >= 10 then price*1.1 else price end) from Orders
February 7, 2006 at 7:35 am
Make sure you have proper indexes on the tables involved. I suggest you equip the #Master table with a unique clustered index on ID and the #DetailTable with a unique clustered...
February 7, 2006 at 5:17 am
Could you post a small example of a parent/child hierachy together with the output you are looking for?
February 7, 2006 at 3:02 am
Try this left join:
select a.question, c.answer, count(b.answer)
from questions a
cross join
(select 'Y' as answer union select 'N' union select 'U')
c
left join answers b on a.qid = b.qid and c.answer = b.answer
group...
February 7, 2006 at 2:50 am
You could also try the following, which doesn't use a temp table:
Select Field1, Field2, Field3 from Table
order by
case when [Condition1] then Field3 else null end,
case when [Condition1] then Field2 else null...
February 7, 2006 at 2:32 am
It is probably better to create a permanent table like the following:
testtable(SPID int, RecordId int)
Then, when you insert data into it, do as follows:
delete testtable where SPID = @@SPID
insert testtable...
February 6, 2006 at 3:09 am
You could access the temptable inside your stored procedure. Or you could pass the record-ID's to the stored procedure in a comma separated string.
If this doesn't help, please give us...
February 6, 2006 at 2:31 am
Alternatively (using KH's table definitions):
select m.ID, m.Field1, m.Field2, d1.Field1 as Detail_R1_F1, d2.Field1 as Detail_R2_F1, d3.Field1 as Detail_R3_F1
from #MasterTable m
left join #DetailTable d1
on m.ID = d1.ID and d1.Record = 1
left join...
February 6, 2006 at 12:57 am
You don't have to do that much typing... In your favourite programming language, write a loop with 87 (or 150) iterations to produce the query you are after. Then copy...
February 6, 2006 at 12:45 am
Nice solution, Vasc... But you might want to use
WHERE DATEDIFF(wk,@StartDay,[date]) + 1 <= Col1
instead, otherwise the first data returned will be from the...
February 3, 2006 at 9:45 am
You didn't write what the problem was But I guess your query fails. Try this instead:
SELECT UserEmail, UserDisplayName, CASE
WHEN DATEADD(mi, -10, GETDATE()) <...
February 3, 2006 at 5:01 am
I realised that there may be a problem with David B's second suggestion. Consider the example below. David B's suggestion returns 1, 4, 5. If my interpretation is correct I...
February 3, 2006 at 2:05 am
Is this what you are looking for?
declare @newtable table(InvNum int, InvCrtDt datetime, InvPstDt datetime, Balance int, RunningBalance int, ZeroDte bit null, Days int null)
insert @newtable
select b.InvNum, b.InvCrtDt, b.InvPstDt, b.Balance, sum(c.Balance),...
February 2, 2006 at 9:49 am
Very nice and certainly better than my suggestion
February 2, 2006 at 4:23 am
I think we read the following differently:
The related table tells which games are related to which, but how do I get the select statement to realize that it should not...
February 2, 2006 at 2:30 am
Viewing 15 posts - 91 through 105 (of 414 total)