Im using Entity Framework and have this two classes: And I instance a new Product like this: When I add and save this object, does not record it in the database, but if I instance the product with a NULL value in the Client attribute, does appear but with that NULL value. I dont know why this is happeningR…
Using PostgreSQL COPY
I’m using JMeter for insert summary data file to PostgreSQL. I tried copy instead of COPY but I’m getting error at copy syntax. I found out COPY is for only server-side, so I us copy for client-side. Here is my query Here is the error: org.postgresql.util.PSQLException: ERROR: syntax error at or n…
Postgres Function exists in a particular schema
I have postgres DB which has multiple schemas, is there a way (query) which I can run to figure out if a function exists in a specific schema or in other words print a list of schema names under which a given function exists. Answer You can adapt following query:
how do i name a similar column from sql with different column names in a select statement
There is a column ‘client_code’ in sql table ‘tb_accounts’. I want to create a select statement with two column aliases ‘cl_code’ and ‘acc_num’, but all populated from the ‘client_code’ column. Answer Select results are aliased like:
store function into variable that expects parameters
So given the following example query I want to fetch all documents created in a range of two dates. As you can see I put some calculations into variables because I can reuse them in the WHERE clause. Further those calculations only differ by one value, the month at the end. So the calculation could also be Is…
Exclude specific rows from table in Stored Procedure
I have a table named Blacklist and table named Order. Both have CustomerId column. Stored Procedure ExecOrder manipulates Order table. My goal is to exclude Orders that have Blacklisted CustomerId (meaning : Order’s CustomerId is in Blacklist table). I edited ExecOrder SP like this: @Temp table returns …
Problem in using group by statement in sql
I am not able to group by table which has all the values same but has two rows. I am not understanding what is the reason behind that. After running this query i am getting the table below and i want to group the table along the LOT_No. TABLE : Now when i am trying to Group by LOT_No, i
how to create fraud detection with SQL?
I have a scenario where: User A is (fraudster). User B is not (fraudster). However, the system will not allow user B to do any action. Because B and A are using the same Phone Number(Shared attribute …
value in column between commas delimited
I have data in the table where all values in the column between double commas example: ‘EGHU3158543’ when inquiry the data I need to delete the first comma and last comma, I used the following code : it gives me error as result : Invalid length parameter passed to the LEFT or SUBSTRING function. A…
How to calculate average for every month from start from year in Presto’s SQL (Athena)?
Below is an example of the table data I have I would like to generate a result set as below I tried to use window function OVER() and PARTITION() but I managed to get average on month by month rather than starting from the year. Any suggestions, please. Thanks Answer I think you want: This puts each year in a