HI there,
Can someone please help with a query I have? Basically I want to return all rows in a table that have multiple date entries that are different. For example:
1636 1073746475 342 2005-12-30 00:00:00.000
1636 1073746475 359 2006-03-10 00:00:00.000
This security 1636 has two entries in the DB with different dates. They are lots of securities with multiple entries with the same date but I need a list of the ones with different dates. Any ideas please?
Thanks!!!!!
Sselect security,
count(distinct datevalue) as datecount
from [yourtable]
group by security
having count(*) > 1|||You handle all the tough questions...time to shovel snow|||Thanks that's a great help, much appreciated!!!
S
Showing posts with label entries. Show all posts
Showing posts with label entries. Show all posts
Wednesday, March 21, 2012
Tuesday, March 20, 2012
Query to return count of items missing every hour
Hello,
I have been trying to work on a query to return the amount of entries
that are not in each hour. There is a problem with the syncronisation
between our databases and I want to find a pattern, in the hours or in
the tags on what is not syncronising. In one DB (primary) I have the
full 6000 records, per hour, over the span of a weekend the backup
site was short about 200 records.
An example of the tables is
TableA TableB
tagId tagName tagId
gmt_time(hourly)
PK composite PK
approx 6000 records approx 6000 every hour
So essentially I would like to see if anyone would know a query that
would group by the hours and return which tags were not present in
that hour.
Thank you in advance for any help.
Andy McDonaghselect tagid, datepart(d, gmt_time) as dy, datepart(hh, gmt_time) as hr
from tablea a (nolock)
where not exists (select * from tableb b (nolock) where a.tagid = b.tagid)
group by datepart(d, gmt_time), datepart(hh, gmt_time)
TheSQLGuru
President
Indicium Resources, Inc.
<mcdonaghandy@.gmail.com> wrote in message
news:1184775962.160779.8450@.x35g2000prf.googlegroups.com...
> Hello,
> I have been trying to work on a query to return the amount of entries
> that are not in each hour. There is a problem with the syncronisation
> between our databases and I want to find a pattern, in the hours or in
> the tags on what is not syncronising. In one DB (primary) I have the
> full 6000 records, per hour, over the span of a weekend the backup
> site was short about 200 records.
> An example of the tables is
> TableA TableB
> tagId tagName tagId
> gmt_time(hourly)
> PK composite PK
> approx 6000 records approx 6000 every hour
> So essentially I would like to see if anyone would know a query that
> would group by the hours and return which tags were not present in
> that hour.
> Thank you in advance for any help.
> Andy McDonagh
>
I have been trying to work on a query to return the amount of entries
that are not in each hour. There is a problem with the syncronisation
between our databases and I want to find a pattern, in the hours or in
the tags on what is not syncronising. In one DB (primary) I have the
full 6000 records, per hour, over the span of a weekend the backup
site was short about 200 records.
An example of the tables is
TableA TableB
tagId tagName tagId
gmt_time(hourly)
PK composite PK
approx 6000 records approx 6000 every hour
So essentially I would like to see if anyone would know a query that
would group by the hours and return which tags were not present in
that hour.
Thank you in advance for any help.
Andy McDonaghselect tagid, datepart(d, gmt_time) as dy, datepart(hh, gmt_time) as hr
from tablea a (nolock)
where not exists (select * from tableb b (nolock) where a.tagid = b.tagid)
group by datepart(d, gmt_time), datepart(hh, gmt_time)
TheSQLGuru
President
Indicium Resources, Inc.
<mcdonaghandy@.gmail.com> wrote in message
news:1184775962.160779.8450@.x35g2000prf.googlegroups.com...
> Hello,
> I have been trying to work on a query to return the amount of entries
> that are not in each hour. There is a problem with the syncronisation
> between our databases and I want to find a pattern, in the hours or in
> the tags on what is not syncronising. In one DB (primary) I have the
> full 6000 records, per hour, over the span of a weekend the backup
> site was short about 200 records.
> An example of the tables is
> TableA TableB
> tagId tagName tagId
> gmt_time(hourly)
> PK composite PK
> approx 6000 records approx 6000 every hour
> So essentially I would like to see if anyone would know a query that
> would group by the hours and return which tags were not present in
> that hour.
> Thank you in advance for any help.
> Andy McDonagh
>
Subscribe to:
Posts (Atom)