I need some help to do it right in one query (if it possible). (this is a theoretical example and I assume the presence of events in event_name(like registration/action etc) I have 3 colums: From this 3 columns we need to create new table with 4 new columns: Result must be looks like this: What I’ve don…
Tag: sql
how to avoid duplicate entries
I created a form on my website where the user can create an account. I save everything into a database connected to a website. This is how I created a table: CREATE TABLE Customer( CID int(9) not …
Creating Postgres View getting ERROR: column “id” specified more than once
SCENARIO: I have this select statement that JOINs a bunch of tables together: I’d like to create a Postgres View. So wrote it out like this: I keep getting this error: ERROR: column “id” specified more than once QUESTIONS: How do I fix this error? I would like to create a view called “…
Incremental invoice number with multiple users
In my app I have users and invoices (amongst other things). I’m not sure what’s the best way to make sure the invoices of every user start with 1 and go up incrementally. For example: User 1 makes …
SQL Query not displaying correctly
I am running a query and the result is not showing correctly, unfortunately, I am not sure what is the problem. Would anyone be kind enough to provide some assistance please? Query; Result: Answer Your problem is that a field that you select is very big, that’s why it’s shown this way. I’d b…
concat only if column value does not contain any specific prefix
I want to add the prefix to column’s data those who not like if the column’s value is 123,OI:909, 456,OI:789 then it updates to OI:123,OI:909, OI:456, OI:789 I tried following SQL Answer You could try this syntax:
Create group column with values based on join [closed]
I have two tables 1) a customer table 2)Account table. I want to see what accounts are primary and which are secondary accounts. In one table I have accountRowId and AccountNumber. In the other …
Query can not be executed, or waiting too long
I am using MySQL 5.0 and working with some crowded tables. I actually want to calculate something and wrote a query like this: SELECT shuttle_payments.payment_user as user, SUM(-1 * (…
ORA-01873 when calculating the difference between two timestamps
I am trying to produce the number of days between two timestamps, as a precise fractional number. My code is producing ORA-01873: the leading precision of the interval is too small This single line …
Charting the data from database and merging row with the same value
I want to create chart that read the category column in my database.. I have repeating category because its general term and i notice this. I have many “short” slice: I dont have any idea how to …