|
Ahhh!
Brilliant again Richard.
Thanks as always.
Very much appreciated.
modified 29-Sep-15 10:27am.
|
|
|
|
|
Hi,
I am using below code to display times as Pivot table grouped by date, this is basically for fingerprint attendance... I am getting what I want like this:
2012-06-03 10:23:30,10:23:32,10:24:05,10:24:07,10:24:24,10:24:26
How can I make the comma separated values displayed in columns instead of comma so it will be something like this
created_date - time1 - time2 - time3 - time4 --- etc
this is the code:
SELECT created_date, GROUP_CONCAT(created_time)
FROM fingerprint
GROUP BY created_date
Technology News @ www.JassimRahma.com
|
|
|
|
|
update sc_bill_details set dt_open_date=(select dt_bill_date from sc_bill where sc_bill.st_bill_no=sc_bill_details.st_bill_no and dt_bill_date>='1-7-2015')
when m writing above query in sql pane of postgresql database then m getting follwing error...though there is no null value..i have changed date datatype of above tables from timestamp to date.
ERROR: null value in column "dt_open_date" violates not-null constraint
DETAIL: Failing row contains (VC2012030000303, VC20100300266, null, 11, 5, RBS, 1, 40, 40, 0, 14, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0).
and when m writing above query taking different table as an example then am getting desired output...i dont understand whats wrong with it..Please get this issue resolved .
Thanks
|
|
|
|
|
Member 11919722 wrote: Please get this issue resolved . How? We do not have access to your database so we have no way of correcting its content.
|
|
|
|
|
but atleast you can tell me the best possible solutions
|
|
|
|
|
The best possible solution is to learn all about database management. It looks like (but this is a guess since your question is not clear) that you have changed the schema of your database and now some of your records do not match the schema.
|
|
|
|
|
actaually as i said that if i write the query (which i posted in the forum) then i get the error....but if i write the same query using diffrent tables then it gives desired output
|
|
|
|
|
i have checked ...n both the tables are in same schema.
|
|
|
|
|
Then you need to investigate how you have records in one table that contain null values where they are not allowed.
|
|
|
|
|
that is what my issue that m getting null values though there is no column which has no records
|
|
|
|
|
Look at the error message you receive:
ERROR: null value in column "dt_open_date" violates not-null constraint
DETAIL: Failing row contains (VC2012030000303, VC20100300266, null, 11, 5, RBS, 1, 40, 40, 0, 14, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0).
It clearly explains, and shows, that you have a record with a null value where one is not allowed. You need to use your database management tools to find that record and fix its content.
|
|
|
|
|
ya i have checked it but ...there is no null vaue ....i just send u screen shot of my tables then hope u understand my issue ok.
|
|
|
|
|
Member 11919722 wrote: hope u understand my issue Yes, I do understand your issue, but I do not think you do.
Either:
- You have a record in your database that contains a null value, or
- The
select dt_bill_date part of your update query does not find a record, so you are passing in a null value.
So, the solution is to find out why the select part of your update is returning a null value, or why that record contains null in the database.
|
|
|
|
|
thats wt how ,, i searched alot and tried solving but there is no null value though its giving
|
|
|
|
|
Run the select part of your query and see what value gets returned.
|
|
|
|
|
its returning the dates greater than 2015-07-01 without any null rrecords for dt_bill_date column of sc_bill table but i want same record to be displayed for dt_open_date column of sc_bill_detail ...thats what my requirement actually
|
|
|
|
|
I suggest you try modifying your code so it iterates through all the results doing the update for each found record.
|
|
|
|
|
i am not writting any code its only a query which i need to write according to the requirement as i told u btw my approach of writting query is correct ?or any other way to get it...coz i think its the simplest one?
modified 23-Sep-15 3:45am.
|
|
|
|
|
Member 11919722 wrote: i think its the simplest one Yes, but it does not work, so it is not the correct one.
|
|
|
|
|
it did work coz i checked the same query with another two tables which i created as an example...n run same query on those two tables ...and getting desired output as well...so its correct one i think
|
|
|
|
|
So if the query works on different tables with the same structure, then you've proved that the problem is with the data in the tables you're using when it doesn't work.
Since we don't have access to your database, we can't diagnose the problem for you. You'll need to check the data in the problem tables to see why the inner query isn't returning a result.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thanks.... finally i achieved my requirement.
|
|
|
|
|
can u give me ur mail id so that i can send u my tables structure ....
|
|
|
|
|
let me tell you the rwquirement of my query that i have wriiten ...so that u could tell me whether my query is right or wrong according to the requirement..
actually i have two tables sc_bill and sc_bill_details...and i have requirement to get the dates available in sc_bill table ( from july 2015 to till date) to sc_bill_details...is my approch is correct to get the desired output.? i want only query
Thanks
|
|
|
|
|
Read the entire thread to date.
If you run JUST the select:
Member 11919722 wrote: select dt_bill_date from sc_bill where sc_bill.st_bill_no=sc_bill_details.st_bill_no and dt_bill_date>='1-7-2015'
what values do you get? Do you get a record with a NULL date?
|
|
|
|