473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How can I compute my Age_Group field? It's based on a calculated field, CURR_BAMTIME

Expand|Select|Wrap|Line Numbers
  1. USE [REP]
  2. GO
  3. /****** Object:  StoredProcedure [dbo].[rpt_AR]    
  4. Script Date: 12/16/2010 11:35:24 ******/
  5. SET ANSI_NULLS ON
  6. GO
  7. SET QUOTED_IDENTIFIER ON
  8. GO
  9. ALTER PROCEDURE [dbo].[rpt_AR]
  10. AS
  11. BEGIN
  12. SET NOCOUNT ON;
  13. Select
  14. Case
  15. When DB_Source = 'IMVPB' and DATEDIFF(dd, dAssignedDate, DATEADD(dd, 0, Getdate())) 
  16. -(DATEDIFF(wk, dAssignedDate, DATEADD(dd, 0, Getdate())) * 2) 
  17. End CURR_BAMTIME,
  18. Case
  19.     When DateDiff(dd,CURR_BAMTIME,GetDate()) < 4 Then '1-3'
  20.     When DateDiff(dd,CURR_BAMTIME,GetDate()) between 4 and 6 Then '4-6'
  21. End Age_Group,
  22.  
  23. From REP.dbo.IMSRPT 
  24. Where Dateofrequest >= '1/1/2010 12:00:00 AM'
  25. END
  26.  
Dec 16 '10 #1
4 1084
ck9663
2,878 Expert 2GB
Can you post some sample data and your required results?

~~ CK
Dec 16 '10 #2
Sure, thanks for asking.

Say CURR_BAMTME is 1, then Age_Group needs to be "1-3", or if CURR_BAMTIME is 2, then Age_Group needs to be "1-3". All the Whens are not listed to catch all possible values of CURR_BAMTIME, but the 1-3 Age_Group is good enough for the example here.

Thanks, again!
Dec 17 '10 #3
ck9663
2,878 Expert 2GB
How many combination are there? Depending on the combination, you might need a look-up table for your requirement rather that a long CASE statement.

Could you post it like a table? And give some data with different CURR_BAMTIME.

Good Luck!!!

~~ CK
Dec 17 '10 #4
The Age_Group ranges are 1-3, 4-6, 7-13 and 14+. CURR_BAMTIME can be a value from 1-500.
Dec 17 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Allen Browne | last post by:
Subform is based on a single-table query that contains a calculated field: Amount: Round(CCur(Nz(*,0)),2) Continuous subform displays this field in a text box named Amount. As user enters new...
2
by: Mark Kola | last post by:
I have ran into an interesting situation. I have a calculated field based on a combobox column that somtimes is not requerying when I change the combo box value. Combobox cboCustomer 2...
2
by: hhathome | last post by:
In my report I have a calculated DateDiff Field, I also have a calculated count field. I'm trying to get a total of the DateDiff field and dividing it by the count field and I'm having problems --...
1
by: john | last post by:
With the help of this NG I got the following to work in a calculated field in a form: =DCount("*";"MyTable1";"MyField1='abc' AND MyField2='J'") I would like to make another calculated field...
3
by: kelley.l.turner | last post by:
Hi all, I am very new to MS Access so please bear with me! I have created a simple calculated field in my data entry form, yet when I view my data table or try to generate a report based on...
5
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
9
by: Haas C | last post by:
Hi all! Is there anyway I can override a value in a calculated field on a form? For example: I have a form which displays the following fields based on a query: Premium Due field has the...
5
by: CSmith | last post by:
I have a calculated field in a query, it calculates the # of days an employee has been employed using the following statement =datediff("d", , NOW()) by default. When an employee is terminated, I...
6
by: Steve67 | last post by:
Wonder if I can get someone’s help with a problem I am having on where to place an IF statement in VBE. I have created a form in Access 2003 that has an automatic calculated field. Basically you...
2
by: DeanL | last post by:
Hi guys, I'm using a subform to display a list of values from a single table. The form is showing the values in "continuous forms" view and there will only ever be two different values for the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.