My aim is to test if the user and password inserted, existed in Table1. However, if I typed (pink,floyd) which exists in the database count still null and it appears the message “user doesn’t exist”. Here’s my database : Answer It turns that the stocked user and pass parameters in Tabl…
Tag: sql
SQL: Create view using multiple tables and a cursor
I have two tables : ‘pc’ and ‘results’. the table ‘results’ contains so many results of every pc. I need to create view that contains all pc columns and the last result of every pc. I’ve tried this …
Order by case insensitive in oracle
I want to order a following text in following order but, after trying the following query it is not working. values to order is “A”, “B”, “Y”, “Z”, “a”, “b”, “y”, “z”. Expected result “ZzYyBbAa” …
A constant expression was encountered in the ORDER BY list
Below is my dynamic query and it’s not working. It threw: A constant expression was encountered in the ORDER BY list, position 2. Original dynamic query: Extracted Query: If I remove second order by line, CASE WHEN ‘ItemDescription’=’ItemDescription’ AND ‘0’= ‘1…
How to retrieve half of records from a table – Oracle 11g
How can i retrieve (select) half of records from a table, for example, a table with 1000 rows, retrieve 500 (50%) from the table. (in this case i can use rownum because we know the exact quantity of rows (1000) – select * from table where rownum <= 500), but i have to count every table to achieve the…
Using SqlQuery<Dictionary> in Entity Framework 6
I’m trying to execute a SQL query in EF 6. The select query returns two string columns, e.g. select ‘a’, ‘b’, and can have any number of rows. I’d like to map the result to a dictionary, but I can’t …
Writing my own aggregate function in postgresql
I’ve never wriiten my own aggreagtes, only store procedures and I need some advice. I want to write a custom aggregate which is going to return maximum value of the integer rows and incerement it by 10. How can I do that? I tried this: but it didn’t work. Can someone help me out? I got the error: …
Save datetime in sql table
How I can insert with a query a date like this? 2015-06-02T11:18:25.000 I have tried this: But I have returned: I tried also: but it is not working: The entire query is: What is wrong? Answer Try this: 126 relates to ISO8601, which is the format yyyy-mm-ddThh:mi:ss.mmm. This is the same format as the string &…
RANDBETWEEN for SQL Server 2012
How would you create a function that returns a random number between two number? example syntax RandBetween(3,300) Answer How about Use RAND() (which returns a value between 0 and 1 (exclusive). multiply by 298 (since you want a dynamic range of [300-3] = 297 + 1) add 3 to Offset and cast to INT? i.e. Fiddle …
I have error “#1363 – There is no NEW row in on DELETE trigger “
I have table “book” and “store_order” have relation I want to make trigger(but it contain error): Answer