Viewing 15 posts - 1 through 15 (of 20 total)
Eirikur Eiriksson (11/12/2014)
Koen Verbeeck (11/12/2014)
David Burrows (11/12/2014)
However max(rate) over( partition by product) will not work if the rate varies +/- and the latest value by date is needed
In that case...
November 13, 2014 at 9:24 am
The following query calculates the SD and MEAN by customer (it doesn't include order_date).
select PO.customer_id
,PO.order_date
,row_number() over(partition by order_date order by order_date desc) as DATE_LINE
...
November 11, 2014 at 9:27 am
Here is another alternative
Add a date column (REC_ADD_DATE) to the table, instead of ClientNum. Default the date column to current_date. This date will then be used to determine...
November 3, 2014 at 8:57 am
-- Here is SQL SELECT query to use when inserting a new row into the table.
-- But ClientNum will remain accurate as long as the rows are not deleted...
October 31, 2014 at 2:40 pm
Here is another alternative..
select TheDate
,TheMonth
,WeekName
,ParcelCount2013
,case when TheDate is not null and TheDate > '2014-10-02' and TheDate < '2015-01-01' then ParcelCount2013 +...
October 31, 2014 at 1:42 pm
I believe the CHARINDEX returns 0 if the delimiter is not found in the string. Tweaked the customer number formula a little bit to handle these scenarios
CASE WHEN coalesce(byte#_of_last_dash,...
October 16, 2014 at 2:32 pm
Here is an alternate solution to your problem...
The following recursive query locates the last delimiter and parses the record into cust_name and cust_nbr.
In the recursive query, at every iteration...
October 14, 2014 at 11:40 am
Is it that you want the books that have the same price and sold by ALL the resellerIds you have in the table ? This is one way to accomplish...
October 27, 2011 at 11:02 am
The INNERJOIN subquery ensures that you have more than one reseller_ids for the book_code with the same price.
NO_OF_RESELLERS_SELLING_SAME_BOOK_FOR SAME_PRICE is how many resellers are selling the same...
October 27, 2011 at 10:22 am
That's true, I kind of overlooked the conditions in the where clause. Thanks for your comments
October 21, 2011 at 8:23 am
I am glad I could help
October 20, 2011 at 8:54 am
I am assuming the IntWOSO table joins both WorkOrders and ServiceOrders tables.
The MAX in the GROUP BY subquery ensures you have only one row per WorkOrder and HAVING clause eliminates...
October 20, 2011 at 8:13 am
I am new to this forum. I didn't know the post can be edited. thanks for the tip.
There was indentation in the query before I posted....
October 15, 2011 at 1:09 pm
I had posted the incomplete query by mistake.
sorry for the confusion, here is the query that I wanted to post.
select A.*, B.Value
from #Records A
...
October 14, 2011 at 9:07 pm
select *
from #Records A
left outer join
(select join_value, max(value)
from #Records M
left outer join #MoreRecords N on M.join_value = N.join_value
where M.date >= N.date
group by join_value
) R on A.join_value...
October 14, 2011 at 7:14 pm
Viewing 15 posts - 1 through 15 (of 20 total)