|
Thanks for the reply/link but that code is for C# and I'm working in SQL unless I'm missing something.
I've never used this site before and haven't figured out the navigation.
|
|
|
|
|
kjfoley1 wrote: I'm working in SQL unless I'm missing something
No but it is Richards job/privilege as a protector to reduce cross posting, which this may not be.
Sorry to not be of any use - I hate xml.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
There has been an error processing your requestError in file: "D:\xampp\htdocs\magento\app\code\core\Mage\Customer\sql\customer_setup\install-1.6.0.0.php" - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'customer_entity' already existsTrace:#0 D:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Resource\Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')#1 D:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Resource\Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '1.6.2.0.1')#2 D:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Resource\Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('1.6.2.0.1')#3 D:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()#4 D:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()#5 D:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()#6 D:\xampp\htdocs\magento\app\Mage.php(683): Mage_Core_Model_App->run(Array)#7 D:\xampp\htdocs\magento\index.php(87): Mage::run('', 'store')#8 {main}Error log record number: 1319383624
|
|
|
|
|
"D:\xampp\htdocs\magento\app\code\core\Mage\Customer\sql\customer_setup\install-1.6.0.0.php" - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'customer_entity' already existsTrace:#0
That suggests that you already have the database created. Delete all the associated files and try again. Although it may be better to spend some time reading the documentation first.
|
|
|
|
|
thank you very much,i will try again!
|
|
|
|
|
This is my table
RowNumber TestDate
1 2014-01-01 00:00:00.000
2 2014-01-04 00:00:00.000
3 2014-01-05 00:00:00.000
4 2014-01-06 00:00:00.000
5 2014-01-10 00:00:00.000
I want to Make Out Put Like this
RowNumber StartDate EndDate
1 2014-01-01 00:00:00.000 2014-01-01 00:00:00.000
2 2014-01-04 00:00:00.000 2014-01-06 00:00:00.000
3 2014-01-10 00:00:00.000 2014-01-10 00:00:00.000
|
|
|
|
|
Then you really need to explain the criteria for selecting the various items. As displayed above it is not obvious how you choose which dates.
|
|
|
|
|
Try this, changing Modified and TableName to suit.
SELECT D.Dt, max(Modified)MaxDT,MIN(Modified)MinDT
FROM TableName N
INNER JOIN (SELECT DISTINCT CONVERT(DATE,Modified) Dt
FROM TableName ) D ON D.Dt = CONVERT(DATE,N.Modified)
GROUP BY Dt
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
This sql not getting the correct Out put, it shows like this
Dt MaxDT MinDT
2014-01-01 2014-01-01 00:00:00.000 2014-01-01 00:00:00.000
2014-01-04 2014-01-04 00:00:00.000 2014-01-04 00:00:00.000
2014-01-05 2014-01-05 00:00:00.000 2014-01-05 00:00:00.000
2014-01-06 2014-01-06 00:00:00.000 2014-01-06 00:00:00.000
2014-01-10 2014-01-10 00:00:00.000 2014-01-10 00:00:00.000
I want to get it like this way
RowNumber StartDate EndDate
1 2014-01-01 00:00:00.000 2014-01-01 00:00:00.000
2 2014-01-04 00:00:00.000 2014-01-06 00:00:00.000
3 2014-01-10 00:00:00.000 2014-01-10 00:00:00.000
|
|
|
|
|
Then you are screwed, there is no indication that the 5th is not the end of a job. You have not supplied enough information.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If I understand the problem correctly, a start date means the preceeding date in not in the table; an end date is the last successive date from a start date in the table or the start date if there are no successive dates.
So...
2014-01-01 is a start date because 2013-12-31 doesn't exist; 2014-01-01 is the end date because 2014-01-02 doesn't exist.
2014-01-04 is a start date because 2014-01-03 doesn't exist, giving 2014-01-06 as the end date.
And so on...
Given that, provide the SQL statement you are using and someone may help; don't ask them to write everything for you.
|
|
|
|
|
How do you expect us to find out code for that transformation if you refuse to tell us the transformation rules?
|
|
|
|
|
Hi.
I have just starting learning database so this would be a rather basic question but I can't figure out how to achieve this.
I have a table in database in which there is a column named Date where I store a date( Just the date in the format dd/mm/yy) and there is another column named IntegerColumn in which initially I am storing the integer value 0.
Question is
How to increment the interger value 0 by 1 in IntegerColumn when the date in Date is less then the current date.
Note that the data type for the column storing the date is nvarchar(50) and I am keeping in check the date format i.e dd/mm/yy through code behind in my asp.net application. And additionally I am using SQL Job Scheduling for the query to recur each time SQL Server finds the date less then the current date.
I have done this much...
DECLARE @IncrementValue int
SET @IncrementValue = 1
UPDATE tableA SET IntegerColumn = IntegerColumn + @IncrementValue
WHERE Date < GETDATE()
|
|
|
|
|
I would recommend that you change the datatype of your date column to datetime - that's what it's there fore!
Also, give your column a more meaningful name then Date - that is a reserved word and may cause you trouble in the future.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Chris thanks for the reply. Chris I infact changed the datatype to date and additionally my column name is actually ReturnDate not Date, I had chose just a random name. But still when I execute the query it does not increment the value in Column. Any more suggesstions ?
|
|
|
|
|
If you are using SQL Server, you don't need to run a job to do this - you can have a computed column.
Create a column Called Days (or whatever you want to call it). Do not set a data type. In the computed column formula enter
datediff(d,[DateColumn], Getdate()) - this calculates the number of days between the [DateColumn] and teh current date
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
You avoided a nasty situation (and comment) by changing to date format in your database, ALWAYS store date in the correct format.
If you go down the path you describe, your are going to have to run the query EVERY day. As Chris suggested use a virtual computed column, I would use a view for this. Do not store the value, a view will automatically calc every time you access it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks RAH for the reply. Firstly I agree with the format thing. Secondly I want the increment to be totally automatic and should occur without any interference( i mean without accessing it ). I hope I understood you right in this because I have never used a virtual computed column or a view before. Do the ones you have suggested do it automatically. If they do so i'll surely have a try.
|
|
|
|
|
As I said earlier, using a computed column you do not need a job to run at all
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
hilbiazhar wrote: I want the increment to be totally automatic Title claims otherwise.
hilbiazhar wrote: should occur without any interference( i mean without accessing it A computed column would be calculated when it's value is requested. Why should it be without any interference? If you don't look at the number, then what is the use of incrementing it in the first place?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Oh i got it now. Actually I had not understood it properly. Thanks for making it clear anyway. Definitely this would be a good approach than keeping SQL Job Schedules like you said.
|
|
|
|
|
/* 2:Display the patient_id, patient_name, phone number( +91-999-999-9999 format) , type_of_ailment .
type of ailement is decided with the number of days stay in hospital.
if stay <=5 ---- Minor
if stay >5 and <=15 days ----Medium
if stay >15 days ---- Major */
I have 2 tables room_allocation and patient_master where pid is the primary key of patient_master table and it also happens to be foreign key in room_allocation table.
1)Columns of patient_master table are(pid Varchar(5) Primary Key,
name Varchar(20) Not Null,
age int Not Null,
weight int Not Null,
gender Varchar(10) Not null,
address Varchar(50) Not Null,
phoneno varchar(10) Not Null,
disease Varchar(50) Not Null,
doctorid Varchar(5) Not Null,
constraint patient_master_doctorid_fk foreign key(doctorid) references doctor_master(doctorid))
2)columns of room_allocation table are
(room_no varchar(5),
pid varchar(5),
adm_date date,
release_date date,
constraint room_allocation_room_no_fk foreign key(room_no) references room_master(room_no),
constraint room_allocation_pid_fk foreign key(pid) references patient_master(pid))
--------------------------------------------------------------------------
I have written the following querry for above question but it gave a syantax error.
-------------------------------------------------------------------------
select p.pid,p.name,concat(
case (release_date-adm_date)
when (release_date-adm_date)<=5 then
when ((release_date-adm_date)>5 and (release_date-adm_date)<=15) then
else
end as
from patient_master p,room_allocation r
when (release_date-adm_date)<=5 then minor
when (release_date-adm_date)>5 and when (release_date-adm_date)<=15 then med
from patient_master p,room_allocation r
where p.pid=r.pid ;
|
|
|
|
|
Look at your query closely, and you will see that you have duplicated the when clauses in the second half of the query
select p.pid,p.name,concat('91-',p.phoneno),
case (release_date-adm_date)
when (release_date-adm_date)<=5 then 'minor'
when ((release_date-adm_date)>5 and (release_date-adm_date)<=15) then 'medium'
else 'Major'
end as 'type_ailment'
from patient_master p,room_allocation r
when (release_date-adm_date)<=5 then minor
when (release_date-adm_date)>5 and when (release_date-adm_date)<=15 then med
from patient_master p,room_allocation r
where p.pid=r.pid ;
Everyone dies - but not everyone lives
|
|
|
|
|
Thanx for replying.I have duplicated the when clauses but I need to test for each condition so what can be the exact alternative.I tried removing the second when clause and replaced it with else clause but still it does not work.Should I go for nested if.
|
|
|
|
|
select p.pid,p.name,concat('91-',p.phoneno),
case
when (release_date-adm_date)<=5 then 'minor'
when (release_date-adm_date)<=15 then 'medium'
else 'Major'
end as 'type_ailment'
from patient_master p,room_allocation r
where p.pid=r.pid
|
|
|
|