Viewing 15 posts - 2,671 through 2,685 (of 10,144 total)
Mark Cowne (1/28/2015)
ChrisM@Work (1/28/2015)
GilaMonster (1/28/2015)
Bhushan Kulkarni (1/28/2015)
Optimized one..
USE [AdventureWorks2008]
GO
SELECT P.*
FROM
Person.Person P
WHERE
P.BusinessEntityId & 1 = 0
That doesn't return alternate rows, it returns rows with odd values of...
January 28, 2015 at 5:03 am
ayh1 (1/28/2015)
I tried altering the third line to:SUM(CASE WHEN a.AttendanceStatus = 2,3,4,5,6,7 THEN 1 ELSE 0 END) AS [Did not attend]
and I tried
replacing the commas with OR
SUM(CASE WHEN...
January 28, 2015 at 4:57 am
GilaMonster (1/28/2015)
Bhushan Kulkarni (1/28/2015)
Optimized one..
USE [AdventureWorks2008]
GO
SELECT P.*
FROM
Person.Person P
WHERE
P.BusinessEntityId & 1 = 0
That doesn't return alternate rows, it returns rows with odd values of BusinessEntityID. There's a...
January 28, 2015 at 4:56 am
Here's another way:
;WITH Preaggregate AS (
SELECT Grp, [Result] = SUM(numLow) + SUM(numMedium) + SUM(numHigh) + SUM(numZeroScore)
FROM historyTable h
CROSS APPLY (
SELECT [Grp] = CASE
WHEN h.asAtDate > DATEADD(DAY,-7,CAST(GETDATE() AS DATE)) THEN...
January 28, 2015 at 4:53 am
ayh1 (1/28/2015)
yep did not attend can correspond to 2,3,4,5,6,7
Good...so what do you think the query should look like?
January 28, 2015 at 4:30 am
Bhushan Kulkarni (1/28/2015)
Optimized one..
USE [AdventureWorks2008]
GO
SELECT P.*
FROM
Person.Person P
WHERE
P.BusinessEntityId & 1 = 0
Almost...
SELECT n, n%1, n%2
FROM (VALUES (1),(2),(3),(4),(5)) d (n)
January 28, 2015 at 4:23 am
ayh1 (1/28/2015)
SUM(CASE WHEN a.AttendanceStatus = 2 THEN 1 ELSE 0 END) AS...
January 28, 2015 at 4:06 am
Bhushan Kulkarni (1/28/2015)
USE [AdventureWorks2008]
GO
SELECT P.*
FROM
(SELECT *,ROW_NUMBER() OVER(Order by BusinessEntityId) AS RID FROM Person.Person )P
INNER JOIN (SELECT ROW_NUMBER() OVER(Order by BusinessEntityId) *...
January 28, 2015 at 4:03 am
ayh1 (1/28/2015)
I have a query which works:
SELECT dbo.tblGP_Practices.OrganisationCode, SUM(dbo.tblAppointments.AttendanceStatus) AS [Total Attended], dbo.tblAppointments.AttendanceStatus
FROM dbo.tblGP_Practices INNER JOIN
...
January 28, 2015 at 3:57 am
satishkmr538 (1/28/2015)
A simple Query to select alternate rows from a table ?
Use ROW_NUMBER() and select either even or odd numbers.
January 28, 2015 at 3:46 am
Lynn Pettis (1/27/2015)
... Mark one off, 31 days on the calendar to go. 31 days on the calendar to go, 31 days to go, ...
A standard month. It will be...
January 28, 2015 at 3:45 am
cyberdaemon (1/27/2015)
I am having problem with the unpivot function of sql 2012, i unpivot my column then i get the result that i wanted but the error that i...
January 28, 2015 at 2:33 am
-- You may need to extend the range of the virtual tally table.
SELECT [QuarterName] = 'Q' + DATENAME(qq,DATEADD(QQ,n,startdate)) + ' ' + CAST(YEAR(DATEADD(QQ,n,startdate)) AS VARCHAR(4))
FROM (SELECT startdate = '01/JUN/2011', enddate...
January 27, 2015 at 6:06 am
Jeff Moden (1/26/2015)
--===== Conditionally drop the working table to make reruns in SSMS easier
IF OBJECT_ID('tempdb..#QU','U') IS NOT NULL
...
January 27, 2015 at 1:57 am
Gosh :blush: thanks Koen! I like what Jeff's done with it.
January 27, 2015 at 1:47 am
Viewing 15 posts - 2,671 through 2,685 (of 10,144 total)