Hi all,
I have, let's say, 1 column called Payment_type.
In the column, there are 6 types of values: 1, 2, 3, 4, 5, 6, like in
---------------------------------
Payment_type |
---------------------------------
1 |
---------------------------------
3 |
---------------------------------
2 | etc where 1 is cash, 2 is bank, 3 is ATM etc
and another column, called amount, containing the amount.
I want to select this way:
---------------------------------------------------------------------
BANK | ATM | CASH | ETC...|
---------------------------------------------------------------------
200 | 134.33 | 450 | 222 |
How can I do it?
First of all, I don't know how to output more than one column from single column...
1 6636
Hi
You can use Sum and Decode functions for your query like:
Select
Sum(Decode(Payment_Type, 1, 1, 0)) CASH,
Sum(Decode(Payment_Type, 2, 1, 0)) BANK,
Sum(Decode(Payment_Type, 3, 1, 0)) ATM, .....
from
[Table Name]
Bye!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Randell D. |
last post by:
Folks,
I have a SELECT that returns with multiple records - It works when I have a
LIMIT clause but when I try to include a GROUP BY clause, the select returns
nothing (ie no records, no...
|
by: mlrehberg |
last post by:
Hi,
New to writing sql script
I get this error in my sql script
Server: Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the
subquery...
|
by: Terri |
last post by:
Hi,
I'm using the following code to build a concatenated string from a
multi-select combo.
For Each varItem In Forms!frmreports!Combo1.ItemsSelected
strSQL = strSQL &...
|
by: NYprmr |
last post by:
Hi All,
I'm trying to get value from Listbox where Multi Select property is
set to Simple, meaning multiple values can be selected.
Doing regular loop like following, retuns NULL value for each...
|
by: pb648174 |
last post by:
I have the following basic statements being executed:
Create a temp table, #TempPaging
Insert Into #TempPaging (Col1, Col2)
Select Col1, Col2 From SomeOtherTable Order By Col2, Col1
Select...
|
by: rich |
last post by:
I have a database with 1 to many and the many is a list with multiple
selects in a list. When I click on a master record I have as part of
my form the select statement for the multiple choice...
|
by: clinttoris |
last post by:
Hello,
If someone could help me it would be appreciated as I am not having
much luck.
I'm struggling with my asp code and have some questions relating to asp
and oracle database.
First...
|
by: Izzy |
last post by:
I'm writting an app that has two DataGridViews, in the first grid I
load a list on companies. Between the 2 grids are two buttons with
arrows, one points to the right the other to the left.
When...
|
by: ssjay1981 |
last post by:
Hello All,
I am new to ms-access, i have a table with values as mentioned below. Each of these table are given with a list of Look up values, in order to narrow down the list of values under...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |