Top 10 Month Comparison
Aug 31, 2007
Not sure if possible but I need to produce a monthly TOP 10 Ticket Category report which I retrieve with:
SELECT TOP (10) Category, COUNT(Category) AS Count
FROM table
WHERE (DATEDIFF(mm, open_date, GETDATE()) = 1)
GROUP BY Category
ORDER BY Count DESC
Now I need to know how many tickets there were for those same categories in the previous month so I want my
result set to look somewhere along the lines of:
Catagory - Count Month - Count Previous Month
Is this possible?
View 4 Replies
ADVERTISEMENT
Oct 24, 2007
Hi,The problem here in hand is comparing the month & year ranges rather than the entire date. I am passing a start month and start year along with the end month and end year, now the query that i have written does not seem to be appropriateMy Query:MONTH(Date_Added) BETWEEN @StartMonth AND @EndMonthAND YEAR(Date_Added) BETWEEN @StartYear AND @EndYearFor some reason this works fine if i specify the startmonth as 1 and endmonth as 12, whereas if i specify 1 and 1 it doesnot work. Can anyone help me by refining my query so that i can search a particular date within mm/yyyy and mm/yyyy. Thanks in advance.Santosh
View 5 Replies
View Related
Apr 5, 2008
Hello what I'd like to display the following in a matrix report:
Parameter selected: 3 (March), 2008 (Year)
Monthly TO Summed up
ArtNo March <=March
1210 20,500 50,900
1220 21,200 64,000
1230 15,400 40,300
... ... ...
So, in the rows I have the articles and in the column the selected month via parameter. In another column I need to sum up all monthly values up to the selected month, meaning in this example the sum of jan, feb and mar per article.
View 3 Replies
View Related
Apr 22, 2015
following table global_usage
ID varchar (contains alphanumeric values,not unique)
Territory (combined with ID unique)
Total_Used int can be null
Date_ date (date of the import of the data)
ID Territory Total_Used Date_
ACASC CAL071287 2014-06-01
ACASC CAL071287 2014-08-01
ACASC CAL071288 2014-09-01
[Code] .....
Now the problem,per month I need the most recent value so I'm expecting
ACASC CAL071287 2014-06-01
ACASC CAL071287 2014-08-01
ACASC CAL071288 2014-09-01
ACASC CAL071288 2014-11-01
ACASC CAL071190 2014-12-14
ACASC CAL071286 2015-01-22
ACASC CAL071165 2015-02-01
ACASC CAL071164 2015-03-01
I've tried a few thing like group,having even row_number() but I keep getting wrong results
View 6 Replies
View Related
Nov 9, 2015
I have two tables Costtable (Id,ResourceId, Amount,Date) and ResourceTable (ResourceId,Name) which shows output as below.
I want to show 0 amount for rest of the name in case of September. For e.g. if rest of the Resources does not appear in cost table they should appear 0 in amount
My Desired output
My current query
SELECT
RG.Id AS Id,
RG.Name AS Name,
ISNULL(SUM(AC.Amount), 0) AS Amount,
RIGHT(CONVERT(varchar(10), AC.[Date], 105), 7) AS [YearMonth]
[Code] ....
View 6 Replies
View Related
Sep 10, 2014
This is my table and data
CVID | WorkExperience
--------------------------------
2838736
68181101
96568122
1135484
I need to convert into this result
CVID | WorkExperience
--------------------------------
283873 years
681818 years 5 months
9656812 years 2 months
1135484 months
View 5 Replies
View Related
Aug 11, 2015
Most of the data is in one table.
Company 1-Jan 1-Feb 1-Mar 1-Apr
RSP RSP RSP RSP
NON-RELO $295 1 $0 0 $1,400 7 $0 0 $1,195 4 $0 0 $4,700 8 $0 0
AMERICAN ESCROW & CL//AECC $2,650 4 $0 0 $3,720 8 $0 0 $2,339 4 $0 0 $2,460 2 $0 0
American Internation//AIRCO $9,131 30 $2,340 9 $10,927 35 $2,340 9 $9,142 31 $2,600 10 $18,406 54 $3,900 15
American Internation//AIR $20,611 63 $1,820 8 $23,892 75 $1,040 4 $35,038 111 $3,120 12 $3,778 16 $1,560 6
American Internation//Ab $64,248 206 $6,240 24 $59,800 187 $5,200 20 $87,115 264
I did something similar doing just record counts but this is far more complicated. I'm at a loss that this is even possible.
SUM(CASE datepart(month, tbFile.openedDate) WHEN 1 THEN 1 ELSE 0 END) AS 'January',
View 2 Replies
View Related
Aug 2, 2002
Does anyone know how I can get last day of month
if I pass a function a given month and and given year.
@Month = 2
@Year = 2004
The result I would need is 29 because there are 29 in
the month of February in the 2004.
Any help on this is greatly appreciated.
Kellie
View 1 Replies
View Related
Jul 29, 2015
My goal is to select values from the same date range for a month on month view to compare values month over month. I've tried using the date trunc function but I'm not sure what the best way to attack this is. My thoughts are I need to somehow select first day of every month + interval 'x days' (but I don't know the syntax).In other words, I want to see
Select
Jan 1- 23rd
feb 1-23rd
march 1-23rd
april 1-23rd
,value
from
table
View 9 Replies
View Related
Sep 10, 2007
Hi I trying to find a way to determine the number of working days per month starting from the current date to the last day of the current month.And within the same store procedure determine the number of working days as normal (each month is independent from the next). For example: The store procedure is executed
September:
@CurrentDate = 9/10/2007
@EndDate = last working day 9/30/2007
Total# of working days = 15
October:
@CurrentDate = 10/1/2007
@EndDate = last working day 10/31/2007
Total# of working days = 23
November:
@CurrentDate = 11/1/2007
@EndDate = last working day 11/30/2007
Total# of working days = 22
etc.
Any ideas of how i can approch this?
Thanks in advance.
View 3 Replies
View Related
Nov 23, 2000
Dear All
I am new to the topic T-SQL.
I am trying to use T-SQL to merge the content of two tables (table1 and table2) into one table making sure there are no duplication.
I wonder if any body can let me have a simple code.
Best Regards
Saad
View 1 Replies
View Related
Sep 13, 2007
Hey guys what would be the easiest way to create a report of value changes for particular records from one day to the next..... ?
Any suggestions would be greatly appreciated....
thanks,
Jonathan
View 2 Replies
View Related
Aug 8, 2006
Hi there! can anyone help me out??? I need to compare a date from the database and the system date which will be coded in a store procedure in SQL... HELP!!!!!
View 5 Replies
View Related
May 21, 2008
I have a table with a field with a bit datatype. When I execute the stored procedure line if @bitvalue = 1 begin ...
and the value is passes as 0 the statements beneath the begin execute. What am I doing wrong?
View 4 Replies
View Related
Jun 27, 2000
Hi...
I have a problem comparing dates in SQL Server 7.
I want to find results where date1 = date2.
I am having problems becausing SQL is also trying to compare the time which
is included in the field value e.g. 03/04/00 12:01:32
So even if the dates are equal the time may be different so the results are not shown?
I've tried SUBSTRING, and CONVERT,CAST etc.. and still can't get it to work
Any ideas???
Thanks.
View 1 Replies
View Related
Oct 3, 2000
Is there a way to compare two similar tables? I'm more interested in finding out if the data content is exactly the same or not between the two tables.
Thanks for your help.
View 1 Replies
View Related
Aug 19, 2003
We are converting our project into new version. They have done lot of changes in new version including normalization/denormalization. I need to compare the old and new database.
Do you have any standard script or procedure like SQL Compare software?.
Let me know what are the possibilties we need to check.
Your help appreciated.
Thanks,
Ravi
View 5 Replies
View Related
Oct 23, 2003
Good day,
I am receiving garbage data from my other department as follows.
I want:
'12/05/03' for example.
I get:
'//'
'00/00/00'
And other garbage. All of which crashes the transaction because it cannot be converted to Datetime.
What I would like to do is something like this:
IF @v_date > '01/01/50'
BEGIN <-- statement will crash if bad data)
Something to trigger a Boolean (True/False) validation of the data.
I want to know if it is even a date before I run it through my block.
Any thoughts?
I don't want to add a new IF block for every bizarre thing they send me.
Thanks ahead of time.
PS - I guess I could just raise an exception and handle it in a block that way, but am still curious.
View 3 Replies
View Related
Dec 11, 1998
Hi friends,
How can I do, in one Trigger, to returns if two columns, one of the Inserted and other of the Deleted, are differents ? I used this example:
If ( select Name from inserted ) !=
( select Name from deleted )
Insert Into Log_System
( Key_Mame, User_Name, Date, Field, Value, Table_Name )
Select 'COD. PROD: ' + Convert( char(10), I.Cod_Prod ),
SUSER_NAME(), GetDate(),
'Name', Convert(Char(255), D.Name ),
Convert(Char(255), I.Name), 'U', 'PRODUCTS'
From Inserted I, Deleted D
But, if one of them is Null, then the comparison result returns FALSE.
Examples:
1 - If in the Table are keeped null and the new value is different of Null
the comparison result returns FALSE.
2 - If in the Table are keeped a value and the new value is null the
comparison result returns FALSE too.
Excuse me, my English is not currently.
Thanks !
Rodney.
View 2 Replies
View Related
May 15, 2001
Hi,
Assuming a table with a column defined char or varchar.
I have a SQL query like this :
Select * from table1 where column1='Building'
It returns the same result that
Select * from table1 where column1='BUILDING'
It is my understanding SQL Server (verison 7 or 2000, I tried on both) is lower/capital insensitive by default when it is installed. If I want SQL Server to be case-sensitive with my char or varchar columns, where can I set it?
Is it at database level or server level I can find this setting . What is the setting that control it?
Best Regards,
Alain Gagne, Lead DBA
gagnea@msagroup.com
View 3 Replies
View Related
Jan 12, 2006
Hello im trying to run a simple query where i compare something simple like BEARING to a field in the database using this query.
Code:
SELECT table1.STK_NO, table1.STK_NO2
FROM table1
WHERE (LEN(CLEANSED_REF)>2)
AND ('BEARING' LIKE '%'+table1.CLEANSED_REF+'%')
Inside the table i can see the CLEANSED_REF field and its value is "000BEARINGBRNG000". When i run the query i get no records returned.
But if i run
Code:
SELECT table1.STK_NO, table1.STK_NO2
FROM table1
WHERE (LEN(CLEANSED_REF)>2)
AND (table1.CLEANSED_REF LIKE '%BEARING%')
The query returns the row i wanted. Can anyone tell me why this wont work the first way, but works the second?
View 4 Replies
View Related
Aug 13, 2004
Morning!
Folks, i want some links where i could find healthy stuff regarding New Features and Compliance levels, performance comparisons, TPC tests etc about SQL 2000 and Yukon specially.
I've to submit a document regarding Top database features that shall be used for a Medical-Billing Software in plan.
Howdy!
View 2 Replies
View Related
Dec 28, 2005
I have two tables that I am needing to link by the tables date field. In one table the date field is defined as varchar(23). The time for this field is always zeros.
Example: '2005-12-27 00:00:00.000'
The other table is defined as datetime, and it does have the date and time in this field.
Example: 2005-12-27 08:00:35.000
The problem i am having is
2005-12-27 00:00:00.000 does not = 2005-12-27 08:00:35.000.
Because I will never have more than one record on the same date I would like to be able to only compare the date. Example 2005-12-27 = 2005-12-27
Since the fields are 2 different field types, this is giving me a problem. Could someone please help. I have tried everything I know to do.
What I really need is the a way to format the datetime fields date into a string such as '2005-12-27'.
Hopefully what i have written makes sense.
Thanks
View 3 Replies
View Related
Oct 4, 2006
I had an application go down yesterday...it was giving a Type Mismatch error and the support team couldn't figure it out.
My suspicion is that a field in the database got populated with a character the vb app didn't like when it renders the information.
I'd like to prove that theory...but the database is large (4gb) and I'm not sure how to do a database comparison to see where the records differ.
Anybody have a script to get me started OR some experience to share?
Thanks,
Alex8675
View 1 Replies
View Related
Jan 22, 2008
In management studio, is there a way to compare databases side by side?
Or would anyone know of any freeware out there that would do such a task?
:beer:
thanks in advance.
View 3 Replies
View Related
May 15, 2008
Hi,
I have a table in sql server 2000.I delete some rows in the table.I would like to know the differences before & after deletion. Is it possible?
View 4 Replies
View Related
Jul 13, 2013
I am doing this 2 queries, they get data from the same tables in a very different way. The new way is a lot faster but of course there are problems. There are some discrepancies in the results. Both queries produce results with more than 200.000 rows. Second one has ca. 100 rows less than the first one and some of the results are wrong (most are correct though).
My question is how do I find the differences. I did the left outer join when column a.result != b.result (lines are defined by date and ID so they should be unique).but the join gives me problematic results (some are not different at all, some differences are not in the result).so how do I find the differences between 2 queries, including missing results/rows?
View 3 Replies
View Related
Jul 23, 2005
I have an Employee table with 3000 records and an Excel file having themodified data of those emplyoees. Some of the data of Excel may be sameas that of table data but some may differ. EmpId is the unique field.Other than this field, other fields of Excel may have modified data.Ineed to compare the data from SQL Server table with Excel Data.I decided to write a VB Program having two recordsets,one for SQLServer and other for Excel and compare each field's value. If themodified value is found then update that to table. Is there any way tocompare in SQL Server itself?Madhivanan
View 2 Replies
View Related
Jul 20, 2005
I am looking for some papers/information that compare relationaldatabases such as oracle, mysql, sql server etc. I am particularlyinterested in their features such as locking mechanisms, integrityconstraints, views... Anyone know where I can find the information?Thanks,Susan
View 3 Replies
View Related
Jul 20, 2005
I'm in need of a sql query that I'm not sure is possible. Here is anexample of how it's laid out.employee ID Job class Last Change Date12345 x 2/1/200412345 y 1/15/200412345 z 1/1/2004We know that this person is in job class 'x' because it's the mostrecent change. Is there a way to write a query that will exclude thelines 'y' and 'z' because they are currently incorrect?I would appreciate any help I could get. Thanks
View 1 Replies
View Related
Dec 29, 2005
As many of you know I've been hunting down a SQL CE alternative / embedded DB that is easily portable among handhelds.
It turns out, that without paying for some other DB, there really aren't any good ones... Unless you go GPL, and the interpretation of GPL that most are using is that your code too is GPL even though you may only Dynamically Link to their app. I think this is likely wrong, but none the less I'm back here yet again.
What I'm looking for this time is a definition of how SQL Server CE is implemented, how it differs from a full blown DB, etc, so I can more thourally explain "why SQL CE" is an embedded DB, and how it isn't the full blown SQL Server that has a bad reputation with some.
My guess is:
SQL Server CE is implemented via DLL. There aren't sockets etc to allow you to connect, and it operates more like an advanced hash on the file system.
Please correct me if i'm wrong, or... send me a link where I can further research. Also, if you have another embedded DB as a suggestion, that's free of course, please point it my way.
Thanks!
View 4 Replies
View Related
Mar 7, 2007
How would one go about writing an expression such as:
var not in (a to g, s to z) in the expression builder to be evaluted with and iif statment
iif(var not in (a to g, s to z),var,"not in listed")
I would rather not have to write this in the SQL statement as a case statement.
View 3 Replies
View Related
Aug 24, 2007
Hi guys,
I'm trying to do a comparison of 2 data sets. Basically what I want is: 'where event date from event number -24 is earlier than the event date for event number -13'
To get the eventdate for the eventno's, I have the following 2 queries:
select eventdate
from caseevent, cases
where eventno = -24
select eventdate
from caseevent, cases
where eventno = -13
So what i'm trying to say is: I want it so that the value of the first query is compared to be LESS than the value of the second query...
Any help please????
Thank you!
View 11 Replies
View Related