Forum: MS SQL Jul 11th, 2008 |
| Replies: 8 Views: 1,217 Can you give me a little more information about what this particular query is trying to do? You may not need to use UNION, but perhaps different JOINs. |
Forum: MS SQL Jul 11th, 2008 |
| Replies: 8 Views: 1,217 Try this:
SELECT
hourStamp,
NULL AS ActualVisits,
SUM(CASE WHEN datestamp < GETDATE() THEN 1 ELSE 0 END) / @numberofdays as HourAverage,
SUM(CASE WHEN dateStamp BETWEEN... |
Forum: MS SQL Mar 24th, 2008 |
| Replies: 2 Views: 3,627 Not sure if this is what you are looking for:
DECLARE tempCursor CURSOR FOR SELECT col3 FROM table1 WHERE col2 = @col2
OPEN tempCursor
DECLARE @value As int --or whatever your datatype is
... |