Viewing 15 posts - 901 through 915 (of 1,183 total)
WITH yourCTEname
AS
(SELECT
CustID
,MAX(OrderDate) AS [Last Order]
FROM Orders
WHERE CustID
GROUP BY CustID)
SELECT
ID,
CustName,
FROM Customers
LEFT JOIN...
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgOctober 4, 2007 at 9:27 am
....but something tells me there's an easier way.
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 27, 2007 at 10:24 am
Include another set of joins...
SELECT
pr.parentprodnodeid
,pr.childprodnodeid
,po.prodnodeid
,pc.sysclassname AS [Parent Class]
,cc.sysclassname AS [Child Class]
FROM
productrelationships pr
LEFT JOIN productobjects po
ON pr.parentprodnodeid = po.prodnodeid
LEFT JOIN productclasses pc
ON po.prodclassid = pc.prodclassid
LEFT JOIN productobjects co
ON pr.childprodnodeid...
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 27, 2007 at 10:23 am
The "Hitchhikers Guide to SQL Reporting Services 2000" is a great book. Although it's for 2000, a lot of it is still applicable.
http://www.sqlreportingservices.net/
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 27, 2007 at 6:49 am
Yes, a table variable would in deed be faster.
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 26, 2007 at 12:45 pm
[p]WITH
problem (problem_name, kount)
AS (SELECT
problem_name = pr.name
...
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 26, 2007 at 12:21 pm
Well, poo! I wasn't thinking of it that way. Of course, if you need info from both CTE's then you'll need to join them in the last select.
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 26, 2007 at 12:06 pm
No, CTE's are only available to the statement immediately following them.
you will want to use a table variable instead.
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 26, 2007 at 11:47 am
But I like random, it's rather difficult to disprove random results... :hehe:
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 26, 2007 at 7:10 am
Change "transactionDate" to "Spend DESC" in my code and you should get what you need.:D
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 26, 2007 at 6:53 am
First you want to get away from procedural thinking. SQL works best set based. Also, post the DDL for your tables, it makes it easier for people to respond with...
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 26, 2007 at 6:23 am
Andras is correct. And easy way to do this would be to throw your PIVOT into a CTE and then you can call it twice in the union.
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 24, 2007 at 9:34 am
You simply put the name of your dataset or group in place of SCOPE. This will return the number of rows in the dataset or group. You do not need...
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 24, 2007 at 9:30 am
It's a little confusing. I'm still not 100% on them (pivot and unpivot) but it's beginning to get clear. DONT ASK ME TO EXPLAIN.. *laughs*
But as you can see the...
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 13, 2007 at 7:30 pm
Simply put, each row from one table is returned with each row from the second or a Cartesian Product is the result set. So if each table has 10 rows,...
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgSeptember 13, 2007 at 10:48 am
Viewing 15 posts - 901 through 915 (of 1,183 total)