Displaying Rows By Month
Sep 17, 2004
Hi All,
I have a column in the table of type datetime.I need to get all the rows in the table but month wise.For Ex:
Jan 2003
(Rows whose date is in Jan 2003)
Feb 2003
(Rows whose date is in Feb2003)
.
.
.
Jan 2004
(Rows whose date is in Jan 2004)
Feb 2004
(Rows whose date is in Feb2004)
.
.
so on...
Can any body give my SQL query to get the desired results.
Thanks a lot,
Kumar.
View 2 Replies
ADVERTISEMENT
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
Jun 4, 2015
I am trying to use one dataset rather than two and was hoping to then filter the data via a table or matrix.
This is my dataset
SELECT
Practice.ibvStaffCategorisation.StaffId
,SUM(Practice.ibvStaffTotalsCL2Y.ChargeableMinutes) AS Sum_ChargeableMinutes
,SUM(Practice.ibvStaffTotalsCL2Y.NonChargeableMinutes) AS Sum_NonChargeableMinutes
,SUM(Practice.ibvStaffTotalsCL2Y.ChargeableAmount) AS Sum_ChargeableAmount
,SUM(Practice.ibvStaffTotalsCL2Y.NonChargeableAmount) AS Sum_NonChargeableAmount
,Practice.ibvStaffTotalsCL2Y.Period
[code]....
I would like to display two rows of data for each StaffId one representing the current period and the other all periods to date so the table would look something like below.
StaffId | Non Chargeable Time | Chargeable Time
CJJ | 0:20 | 4:20
| 4:50 | 19:20
JN | 0:05 | 5:30
| 1:30 | 25:30
The above shows two separate StaffId figures the first line for each shows non chargeable and chargeable for the current period and the second line a total of all periods in that year.
I have managed to get the first row to display only figures from the current period by using a filter however it also applies the same filter to the second row in the group. I have also tried to group the rows but am drawing a blank.
View 6 Replies
View Related
Mar 25, 2007
hi,i wanted to know if there is any sql statement that enables the query to display say first '10' rows only.Eg: suppose SELECT * from Location; returns 25 rows and i want only 10 rows in that to be displayed. How can this be done? Help please.
View 1 Replies
View Related
Oct 12, 2005
I'm pretty sure this can be done just don't know how. I need to combind two rows from the same table in an sql server database into one row that I can then put into a dropdown list. ex.ProductID ProductDescription are the two rows That I need to display in the dropdown list. 12 Backpackshould show up in the ddl as 12 Backpack as a choice.Thanks in advance for the help
View 2 Replies
View Related
Aug 22, 2005
I would like to display data from one column on multiple rows in one row.
Example:
Name Pet
David Dog
Dawn Dog
Dawn Cat
Pete Mouse
Pete Cat
Pete Dog
I would like the result to do the following:
David Dog
Dawn Dog Cat
Pete Dog Cat Mouse
I will not know the row values ahead of time.
View 2 Replies
View Related
Dec 13, 2007
Hi Everybody
I am working with SQL Server2000. I have one table named Table1 is described as below
Column1
----------------------------
Val1
Val2
Val3
Val4
Val5
Val6
Val7
Val8
Now I want result like that
Column1 Column2
-------------------------------------
Val1 Val2
Val3 Val4
Val5 Val6
Val7 Val8
How I acheive this result from a Query ?
View 4 Replies
View Related
Dec 4, 2006
Hello,
I have a seach on UserID enetred in a textbox by user.
When the user types a userID which has no data in the database can I display an error msg instead of the chart and table that is displayed on entering a valid userID.
Thanks,
Kiran.
View 3 Replies
View Related
Jun 20, 2007
Hi,
I have requirement to display Total number of Rows in a Report in Page Header.
I have written the following code in Page header it shows RowCount for the Page only.
=Count(ReportItems!textboxInTableCell.Value)
Can anyone please help on this?
Regards
Raghav
View 3 Replies
View Related
Oct 20, 2014
I am trying to get the number of rows for each month.
table name:sitez
ID Name crDate access
===========================
1 Bob .. 2014-01-11 .. 1
2 Jerry .. 2014-01-22 .. 2
3 Jim .. 2014-05-06 .. 1
4 Jason .. 2014-12-11 .. 1
5 Jen .. 2014-11-21 .. 3
I am using the results to make a bar graph so I am querying the database for a given year and expecting 12 results back (running SQL 2012).
Select count(*) as ttl FROM sitez WHERE year(crdate) = 2014 and access = 1 group by all month(crdate)
This should return:
1
0
0
0
1
0
0
0
0
0
0
1
However when testing the script I was only getting back:
1
1
1
which didn't knowing which months were 0
By changing the GROUP BY to GROUP BY ALL, it now puts in the zeroes. However I'm still having issues with incorrect results.
When I query the database, the results for December 2014 shows '13' when I execute:
Select count(*) as ttl FROM sitez WHERE year(crdate) = 2014 and access =3 group by all month(crdate)
There are ZERO rows made with a year of 2014 and an access of 3.I verified this by going a straightforward select * from sitez where crdate = 2014 and access = 3
Why I'm seeing ghost results?
All I need is 12 results, ordered by crdate month.
View 3 Replies
View Related
Aug 15, 2007
i have a datatable with Part , DateSold,ItemsSold
i want to show the sales for the last 12 months by month. if there were no sales for a given month i want the table to show 0.
here was my first attemp that only gives me data if all twelve months had sales.
SELECT MONTH(DateSold) AS Month, SUM(ItemsSold) AS ThisYear
FROM inv_Monthly_Sales
WHERE (YEAR(DateSold) = @Yr - 1) AND (Part = @Part)
GROUP BY MONTH(DateSold)
ORDER BY Month
i tried using isnull with the sum but that didn't work.
how can i force the table to always generate a dummy table of 12 months and then left join to it and in that way force it to give 12 moths of sales even when it does'n exist.
your help is greatly appreciated,
slimshim
View 15 Replies
View Related
Nov 9, 2014
This is my Statement.
SELECT a.FIRMA,
a.PSNR,
a.FELDNR,
a.PFLFDNR,
a.INHALT AS Cardnr,
a.PFGLTAB,
[Code] .....
But it deliver me also rows which are not in valid. I need only rows from last month from 01.10 until 31.10 and this rows are over the time. How can i select dynamically all row between 01.10 and 31.10 ?
FIRMAPSNRFELDNRPFLFDNRCardnrPFGLTAB PFGLTBISKSTNRPSPERSNRPSVORNAPSNACHNA
13980211DU9572014111220321231000043000957xxxxx xxxxxx
13990211DU9552014110120321231000010000955xxxxx xxxx
14030211DU9602014120120321231000086000960xxxxxxxxx
View 10 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 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 21, 2006
I used to do this with classic asp but I'm not sure how to do it with .net.Basically I would take a table of Categories, Then I would loop through those. Within each loop I would call another stored procedure to get each item in that Category. I'll try to explain, Lets say category 2 has a player Reggie Bush and a player Drew Brees, and category 5 has Michael Vick, but the other categories have no items.Just for an example.. Category Table: ID Category1 Saints2 Falcons3 Bucaneers4 Chargers5 FalconsPlayer Table:ID CategoryID Player News Player Last Updated1 1 Reggie Bush Poetry in motion 9/21/20062 1 Drew Brees What shoulder injury? 9/18/20063 5 Michael Vick Break a leg, seriously. 9/20/2006 Basically I would need to display on a page:SaintsReggie BushPoetry in MotionFalconsMichael VickBreak a leg, seriously.So that the Drew Brees update doesnt display, only the Reggie Bush one, which is the latest.I have my stored procedures put together to do this. I just don't know how to loop through and display it on a page. Right now I have two datareaders in the code behind but ideally something like this, I would think the code would go on the page itself, around the html.
View 1 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
Dec 11, 2006
i have some classes that I want to group by month/year (note:i dont need the day of the month)
how do i wirte my sql so it only gives me the dictinct groups month/year of the classes I have so that it comes out like so..
11/2006
12/2006
1/2007
3/2007
i try with my sql below but i cant get the groups th come out in order. i dont think it sees it as a date value.
dbo.classgiven.classdate date of the class.thank you all
SELECT DISTINCT { fn MONTH(dbo.classgiven.classdate) } " + "/" + "{ fn YEAR(dbo.classgiven.classdate) } AS monthyear,{ fn MONTH(dbo.classgiven.classdate) } AS monthcode FROM dbo.classT INNER JOIN dbo.classgiven ON dbo.classT.classcode = dbo.classgiven.classcode WHERE (dbo.classT.discount = '-1') AND (dbo.classT.coned IS NOT NULL)", conNorthwind )
View 9 Replies
View Related
Oct 26, 2006
Does anyone know of a way to use a funtion for returning records based on fiscal reporting periods like Quickbooks uses for example "This Month", "Last Month", "This Quarter", "Last Quarter", "This Year", "Last Year". While I realize that I can create a very long date time parsing routine for this but it is not very elegant or useful. I thought there might be a way to do this already with an existing function.I have created a stored procedure that I pass a @ViewRange Parameter to and it returns the records that I want but I need this ability in several procedures and wanted to turn it into a stored procedure.IF @ViewRange = 'This Month' SELECT TOP 20 Customer.LastName AS Customer, SUM(Sales.AmtCharge) AS Amount FROM Customer INNER JOIN Sales ON Customer.CustNo = Sales.CustNo WHERE (MONTH(Sales.InvDate) = MONTH(CURRENT_TIMESTAMP)) AND (YEAR(Sales.InvDate) = YEAR(CURRENT_TIMESTAMP)) GROUP BY Customer.LastName ORDER BY SUM(Sales.AmtCharge) DESC;IF @ViewRange = 'Last Month' SELECT TOP 20 Customer.LastName AS Customer, Sum(Sales.AmtCharge) AS Amount FROM Customer INNER JOIN Sales ON Customer.CustNo = Sales.CustNo WHERE(MONTH(Sales.InvDate) = MONTH(CURRENT_TIMESTAMP) - 1) And (YEAR(Sales.InvDate) = YEAR(CURRENT_TIMESTAMP)) GROUP BY Customer.LastName ORDER BY Sum(Sales.AmtCharge) DESC; Any ideas?
View 8 Replies
View Related
Mar 20, 2004
I would like to AUTOMATICALLY count the event for the month BEFORE today
and
count the events remaining in the month (including those for today).
I can count the events remaining in the month manually with this query (today being March 20):
SELECT Count(EventID) AS [Left for Month],
FROM RECalendar
WHERE
(EventTimeBegin >= DATEADD(DAY, 1, (CONVERT(char(10), GETDATE(), 101)))
AND EventTimeBegin < DATEADD(DAY, 12, (CONVERT(char(10), GETDATE(), 101))))
Could anyone provide me with the correct syntax to count the events for the current month before today
and
to count the events remaining in the month, including today.
Thank you for your assistance in advance.
Joel
View 1 Replies
View Related
Feb 2, 2004
I am trying to get my db to return a date in the format day/month/year but its returning the american version month/day/year.
I'm using a DatePart function that converts my date:
CREATE FUNCTION dbo.DatePart
( @fDate datetime )
RETURNS varchar(10)
AS
BEGIN
RETURN ( CONVERT(varchar(10),@fDate,101) )
END
This returns te american version, can anyone help me to get this to convert the UK way.
Thanks
View 3 Replies
View Related
May 6, 2008
In my database . Some to the dates has been stored wrongly .
for example
03/04/2008 to be stored in database . But in my database it was stored as 04/03/2008 . like this i have more that 100 records . How can i change this to correct format using query . Guide me urgent .
View 8 Replies
View Related
Dec 22, 2007
how can i do this
search between 2 rows
day before Last day of the Previous Month + day Last day of the Previous Month"
Code BlockSELECT empid, basedate, unit_date, shift, na
FROM dbo.empbase
WHERE (basedate = DATEADD(d, - 2, DATEADD(mm, DATEDIFF(m, 0, GETDATE()), 0))) AND (shift = 5)
AND
(basedate = DATEADD(d, - 1, DATEADD(mm, DATEDIFF(m, 0, GETDATE()), 0))) AND (shift = 1)
TNX
View 5 Replies
View Related
Oct 28, 2014
I have 3 tables...
JobRequirements (A)
JobID int
QualificationTypeID int
EmployeeQualifications (B)
EmployeeID int
QualificationTypeID int
Employee (C)
EmployeeID int
EmployeeName int
I need to return a list of all employees fit for a specific job ... The criteria is that only employees who have all the JobRequirements are returned. So if a job had 3 requirements and the employee had just 2 of those qualifications, they would not be returned. Likewise, the employee might have more qualifications than the job requires, but unless the employee has all the specific qualifications the job requires they are not included. If an employee has all the job qualifications plus they have extra qualifications then they should be returned...
How to only return those records where all the child records are present in the other table..
View 5 Replies
View Related
Apr 25, 2007
This is what I'm trying to do:
If String AB06 is then I need to get AB05; if it is AB11 I need to get AB10.
My select statement looks like this:
select 'AB'+(cast(substring(period,3,2) as int)-1) from table.
Result is AB6. But I want AB06 (ABzero6)
But when I do this, I'm getting AB6 instead of AB06. Can someone please tell me how to have '0' in front of 6? I guess when I cast it as integer, it is ignoring the leading 0.
Thanks.
View 4 Replies
View Related
Oct 27, 2006
Hi
I am calculating percentage using expression. I want to display % at the end of the result.
If I use P1 or P0 somehow it multiplies the result with 100 I guess.
Here is what my calculated value is
15.384515
and I want to display 15.38%
Using P1 or P0 I am getting 1,538.5%
How can I get the desired result?
Any help would be appreciated.
Regards
Amit
View 5 Replies
View Related
May 7, 2008
Hi there
I got the following returned simple dataset as follow:
Code Snippet
ReportViewType; Category; Name; Units; Price;
LIST_VIEW; FRUITS; Apple; 1; $10
LIST_VIEW; FRUITS; Banana; 2; $11
LIST_VIEW; CARS; Corolla; 8; $100
LIST_VIEW; CARS; BMW; 10; $200
I've managed to grouped by Category field nicely and added extra calculated column for handling to total plus as well as Total for each group plus added a new row for TOTAL in the TABLE and returned as follow:
Code Snippet
FRUITS
Apple; 1; $10; $10
Banana; 2; $11; $22
TOTAL FRUITS; $32
CARS
Corolla; 8; $100; $800
BMW; 10; $200; $2000
TOTAL CARS: $3000
TOTAL: $3032
Now I want to put another extra row underneath TOTAL for handling the calculated but the business rule is only for displaying from the first group for instance:
Code Snippet
TOTAL: $3032
Calculated Average per fruits: $1010.67 ($3032 / 3 UNITS).
3 UNITS is coming from Units for Apple and Banana.
I don't know if I can do this cause i did try to use
Code Snippet
=SUM(IIF(Fields!Category.value = "FRUITS", Fields!Units.Value, 0))
But it's successfully compiled but the report result error (#Error) on that field only. Any ideas?
I thought a simple like this can be handled quite easily instead of creating a new report view type in the the same dataset to handle this particular extra line.
Waiting your comment/feedback.
View 4 Replies
View Related
Feb 16, 2008
I am trying to create a user permission system that is stored in a database. What is the best table structure for accomplishing this? How could I display the permissions in a grid? Currently I have a users table and a permissions table. I created a map between the two. However, I don't see how this allows me to display a grid. All my "columns" for permissions are actually rows from the permissions table. So ideally my grid would look something like this. User | P1 | P2 | P3 |A | T | F | T |B | T | T | T |Thanks for any help. I am relatively new to SQL so please explain gently.
View 2 Replies
View Related
Mar 16, 2006
Hi,
I am a new VWD user and have been trying to set up a website that allows 1 user to upload images into to SQL Express database and then display them with a variety of other fields.
I have searched the forums, several books and many ASP "training" websites to find out how to do this. Every website seems to teach how to display a list of employees or show photo gallery, but none explains how to upload an image, save it in the appropriate field(s) in the database, and then display it when requested in a Datagrid or Details View using VWD and SQL Express 2005
Can any one give me directions to a solution, or send me a simple solution to this?
The best example of what I need is is a real estate listing, wherethe property for sale has 8 to 10 descriptive fields and 1 to 3 images that are displayed.
Any help would be appreciated.
Spacecaetrg.
View 4 Replies
View Related
Jun 18, 2003
I have built an ADP for an internal project. The rpoblem I'm having is that one computer is not displaying reports. No matter who the user is it will not show the reports. I thought it might be a software issue/conflict, so I changed out the hardrive and started with a clean OS with only MS Office installed on it. I have also made sure that the users have access rights to SQL along with all sprocs used in the reports. But I'm still having the same problem. There are four other computers in the office that use the application and all work fine. If anyone has any ideas or suggestions I would be glad to hear them.
View 6 Replies
View Related