Viewing 15 posts - 8,176 through 8,190 (of 10,144 total)
Cool - now plug this new component into your query set in place of the original one which was unordered and giving you dupes.
January 26, 2010 at 4:51 am
-- Make some sample data
DROP TABLE #TableWithStartAndEndDate
CREATE TABLE #TableWithStartAndEndDate (TiD INT, StartDate DATETIME, EndDate DATETIME)
INSERT INTO #TableWithStartAndEndDate (TiD, StartDate, EndDate)
SELECT 1, '2010-01-18 01:00:00.000', '2010-01-25 23:00:00.000' UNION ALL
SELECT 2, '2010-01-18 02:00:00.000',...
January 26, 2010 at 4:46 am
-- Sample data setup for #sipDimensionPos
--===== Create table
DROP TABLE #sipDimensionPos
CREATE TABLE #sipDimensionPos(
[id_pos] [bigint] NULL,
[id_cliente] [bigint] NOT NULL,
[razonSocial_cliente] [varchar](100) NULL,
[id_CliPadre] [int] NULL,
[nombre_CliPadre] [varchar](100) NULL,
[id_canal] [smallint] NULL,
[id_sucursal] [smallint] NULL,
[establecimiento] [varchar](100) NULL,
[nombre_Localidad] [varchar](100)...
January 26, 2010 at 2:49 am
-- @PivotCliPadres populated
-- with distinct values, and in order
DECLARE @PivotCliPadres VARCHAR(1000)
SELECT @PivotCliPadres = COALESCE(
@PivotCliPadres + ',[' + cast(id_CliPadre as varchar) + ']',
'[' + cast(id_CliPadre as varchar)+ ']')
FROM (
SELECT id_CliPadre
FROM...
January 26, 2010 at 2:47 am
There's another way of writing this type of query which might be more intuitive to you, and help you along with your new query. This replaces the query as in...
January 26, 2010 at 2:15 am
TSQL101 at Mumbai Tech.
Graduate as a Senior Software Engineer.
January 25, 2010 at 10:11 am
This might run faster:
SELECT c.crs_id AS id,
c.crs_name,
c.crs_author,
c.sch_start,
c.sch_end
FROM SNP_crs c
--INNER JOIN SNP_crsunits u ON u.crs_id = c.crs_id
--INNER JOIN SNP_media m ON m.crsunit_id = u.crsunit_id
LEFT JOIN (SELECT ud.crs_id
FROM...
January 25, 2010 at 9:04 am
jordon.shaw (1/25/2010)
That's it! You're a genus! Thank you so much for your help!!!
Heh not quite mate, just a jobbing programmer, but thanks.
Do you really need the aggregated columns...
January 25, 2010 at 8:54 am
SELECT c.crs_id AS id,
c.crs_name,
c.crs_author,
c.sch_start,...
January 25, 2010 at 8:30 am
Which output columns vary within the "group by"? Have a gander at them, and decide which of your options would best suit you: MIN / MAX / AVG etc
January 25, 2010 at 8:15 am
No worries mate.
Have a look at this, I reckon it's getting close:
SELECT c.crs_id AS id,
c.crs_name,
...
January 25, 2010 at 8:04 am
jordon.shaw (1/25/2010)
Chris Morris-439714 (1/25/2010)
Nope, wasn't meant to. There are a few questions at the bottom of the code list, any chance of an answer?
I had posted my table structure. ...
January 25, 2010 at 7:38 am
Jeff Moden (1/24/2010)
lobbymuncher (1/24/2010)
Here's a completely different way which returns the codes in the same row.
Oh... be careful... you have to consider how hard the I/O system needs to work...
January 25, 2010 at 6:53 am
jordon.shaw (1/24/2010)
That still isn't working.
Nope, wasn't meant to. There are a few questions at the bottom of the code list, any chance of an answer?
January 25, 2010 at 6:06 am
This is worse than the original query and the suggestions which have been made have not been implemented.
Are you able to create a view or stored procedure on the...
January 22, 2010 at 8:10 am
Viewing 15 posts - 8,176 through 8,190 (of 10,144 total)