[Solved] I need to convert a Postgres specific query to SQL Server (T-SQL)

[ad_1] On SQL-Server use CHARINDEX CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] ) DECLARE @CAMPO30 varchar(64) = ‘2,663.25’; SELECT CASE WHEN CHARINDEX(‘.’, @CAMPO30) > 1 THEN CAST(REPLACE(REPLACE(@CAMPO30,’.’,”),’,’,’.’) AS FLOAT) ELSE CAST(REPLACE(@CAMPO30,’,’,’.’) AS FLOAT) END AS CAMPO30 GO | CAMPO30 | | ——: | | 2.66325 | dbfiddle here 1 [ad_2] solved I need … Read more

[Solved] Pass data from ajax in php

[ad_1] use jquery with ajax & call ajax function onclick of submit button $.ajax(‘URL’, { type: ‘POST’, data: { myData: ‘formdata’ }, // data to submit success: function (data) { console.log(data); } }); 2 [ad_2] solved Pass data from ajax in php

[Solved] SQL or Subquery if possible without using functions

[ad_1] You should use group by and sum, but before that, you should create two subqueries according to n_txn_type_key and then compare: select txn_type_4.n_event_key, txn_type_4.tran_amount from ( select n_event_key, sum(n_transaction_amount) as tran_amount from TABLE_NAME where n_txn_type_key = 4 group by n_event_key ) txn_type_4 inner join ( select n_event_key, sum(n_transaction_amount) as tran_amount from TABLE_NAME where n_txn_type_key … Read more

[Solved] Stored procedure has too many arguments in SQL Server and C# but on second entry

[ad_1] I think you didn’t clear the parameters. You should clear it always after your transaction. cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(“@UserId”, userId); cmd.Parameters.AddWithValue(“@MonthlyIncomeName”, income.MonthIncomeName); cmd.Parameters.AddWithValue(“@MonthlyIncomeAmount”, income.MonthIncomeAmount); cmd.Parameters.AddWithValue(“@TotalMonthlyIncome”, income.MonthIncomeAmount); cmd.Parameters.AddWithValue(“@Month”, insertMonth); cmd.Parameters.AddWithValue(“@Year”, insertYear); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); // insert this line And search about AddWithValue vs Add like @cha said that check your parameter types. See this. 1 [ad_2] … Read more

[Solved] Dividing one column into two columns in SQL [duplicate]

[ad_1] try this: DECLARE @YourTable table (Column1 varchar(50)) INSERT @YourTable VALUES (‘Frodo Baggins’) INSERT @YourTable VALUES (‘Samwise Gamgee’) INSERT @YourTable VALUES (‘Peregrin Took’) INSERT @YourTable VALUES (‘Meriadoc Brandybuck’) INSERT @YourTable VALUES (‘aa’) INSERT @YourTable VALUES (‘aa bb cc’) SELECT LEFT(Column1,CHARINDEX(‘ ‘,Column1)) AS Names ,RIGHT(Column1,LEN(Column1)-CHARINDEX(‘ ‘,Column1)) AS Surnames FROM @YourTable –both queries produce same output SELECT … Read more

[Solved] Update Table if value not exists

[ad_1] There is one problem your not setting value and its empty. By which the values you select wont be added or updated to your database. The second is you have not given the name to your select dropdown by which even if you select the values it wont be posted to your action. <form … Read more

[Solved] SQL Linq syntax [closed]

[ad_1] One way would be like this: db.polls.Where(p => p.id == polls.Where(x => x.publish_at == polls.Max(y => y.publish_at)).Max(x => x.id)); Another way like this: from p in db.polls where p.id == (from x in db.polls where x.id == (from y in db.polls where y.publish_at == db.polls.Max(y => y.publish_at) select y.id).Max()) select x.id).Max()) select p; 1 … Read more

[Solved] How to Count The most common multiple event is SQL

[ad_1] You can use group by: select favorite from t group by favorite order by count(*) desc fetch first 1 row only; This is ANSI-standard sequence. Different databases have different ways of expressing the fetch first clause. In MS Access, this would be: select top (1) favorite from t group by favorite order by count(*) … Read more

[Solved] Convert sql to dql symfony [closed]

[ad_1] I assume that you’re within the context of a repository, so in which case I’d advise using the Doctrine Query Builder, it’d help simplify your code flow, and probably would help you with SQL conversions in the future. To answer this specific problem, you’d probably want to do something like the following: public function … Read more

[Solved] SQL query needed for a complex structure

[ad_1] Without a better understanding of the rules and data this is the best I can come up with. It is based on your first array example – SELECT `r`.* FROM `rule_attribute_value` `rav` INNER JOIN `rule` `r` ON `rav`.`rule_id` = `r`.`rule_id` INNER JOIN `rule_attribute` `ra` ON `rav`.`attribute_id` = `ra`.`attribute_id` WHERE (`rav`.`store_id` = 0 AND `ra`.`attribute_code` … Read more