I’m trying to update my date column which is (eg. 2012-04-20) format in into mm-yyyy. I searched for solutions that you can do by converting to varchar however it gave me an error Msg 241, Level 16, State 1, Line 4 Conversion failed when converting date and/or time from character string. This is the cod…
Tag: sql
How to use IS NOT NULL on a case when?
I have the below SQL query in SSMS where I want to exclude NULL rows that show up in the ‘intercompany budget’ columns. I’ve tried to search for answers and putting a WHERE clause for ‘Intercompany Budget’ IS NOT NULL, like in the query below, but NULL rows still show up. Any sug…
How to validate filleds in mysql for date today and onwards?
I am trying to use the following code alter table Appointment ADD constraint chk_date check( AppointmentDate >= curdate()); However it gives the following error saying that curdate function is …
How to add escape $ in Zend framework query
I need to add escape ‘$’ in zend framework. expected query: SELECT * FROM V_HOME_SEARCH sv WHERE sv.NAME LIKE ‘%gar$_%’ ESCAPE ‘$’ I tried this: public function selectData($str){ $select = $this->…
How can I count total item in an object/record and count only the value = true
obj = {true, false, false , true,…}; This is only one record that I query from database by using Linq The reason is I would like to display Finsished 2 of 7 , that is why I need to count items in a record. Thank you in advance! After I can store numbers in variable, then I would like to
how to ignore the values before and after between the rows in a table
I have a table as like below I have to add a new column to the table as “value_”, which should contains age values for rows between last TRUE i.e row number 4 (highlighted in green color) …
SQL – Compare rows based on date and transpose difference
Scenario: Table ‘HIST’ RID VALUE HIST_DATE 1 V111 2019-01-01 1 V112 2020-02-11 1 V112 2020-03-08 1 V113 2020-04-11 1 V114 2021-03-15 2 V211 2020-04-11 2 V211 2021-03-16 3 V311 2019-05-01 3 …
Select values for a column only if there are no rows with that value that satisfy a condition
I have a table that stores logs of http fetches, let’s say we have two columns: fetch_url and success. A few example rows: success fetch_url TRUE A FALSE A FALSE B FALSE B FALSE …
Why do I get an Error when I try to rename a table after FROM?
When I simply try to retrieve all of the rows in my table EMPLOYEE like this: SELECT * FROM EMPLOYEE AS emp; I get the following error: ORA-00933: SQL command not properly ended 00933. 00000 – &…
How to compare counts from subselect?
I want to compare the count between two tables. Or more to say, output if the count from table1 is greater than from table2: SELECT c1 > c2 FROM (SELECT count(*) from table1) as c1, (SELECT count(*)…