How to insert more than one value into one column using SQL Server [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I need to insert more than one value in columns SellPrice1, SellPrice2.
Because maybe one of my items has 2 or 3 sell prices.

You could either add an [ItemSalePrice3] column, but that could go on for ever, and you usually don't want your DB to grow horizontally instead of vertically.
I would personally add a table like:
item_id price
_________________
1 1,50
1 2,00
2 4,00
And add an entry to that table for each price an item has.

Related

Find distinct from multiple columns [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I have 2 columns called price and PID in database called seatinginfo.
Both columns will have multiple of the same values like
pid 1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3
price 10,10,30,40,60,80,70,90,90,90,90 etc
I'm looking to make a query that will give me a list of all unique prices and pick just 1 or the max connected pid.
So example I only want one price,pid like 10,1 30,1 40,1 60,2 etc
Thanks
This is probably as simple as basic aggregation. Something like this should work based on the pretty vague details.
select price
, max(pid)
from YourTable
group by price

POSTGRESQL: Insert Data from another table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
In above table customer ids are listed what I want to do is to get those ids from this table,
create another table named PROMOTION CLASSES where PREMIUM, PLUS AND NORMAL are in columns and put first 100 ids under PREMIUM COLUMN and soon.
Please help.
This creates you table with classification
CREATE TABLE promotion_classes as
SELECT customer_id,
case when customer_id < 100 then
'PREMIUM'
else
'NORMAL'
END as CLASSES
FROM CUSTOMER_TBL

like i having table1 in that amount column is there but how much amount is there in that column i dont know to display top 10 high amounts [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
like i having table 1 in that amount column is there but how much amount is there in that column i dont know to display top 10 high amounts using sql
As the question misses some details,
SELECT TOP 10 Amounts FROM India_Base
ORDER BY AMOUNTS DESC

Insert into a backup table based on date [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My table in Oracle 11g has 6 fields. I also have a backup table also with no values. The original table has 2 date values. I need to insert into the backup table from the original table the orders having an order-date 5 months back as of today.
The table has a field names ORDER-DATE and has records entered inside.
insert into backup_table
select * from original_table
where order-data > add_months(sysdate,-5);

Problems with SQL query finding three names with the most records [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a table and I want to display the 3 names (Ted, Ringo, Paul) that have the most records using an SQL query.
It's a primitive question, but please help me.
my table:
SELECT TOP 3 Name
FROM YourTable
GROUP BY Name
ORDER BY COUNT(*) DESC