Solved

Out the count variables

Posted on 2016-07-18
6
53 Views
Last Modified: 2016-07-22
Hi all, I would like to get the out of the count...

Select * from tickets where event_ID=20

Output:

2x USD
3x SGD
5x AUD

I Don't want the count, I just want the output.

This is so I can do less queries on the page, relating to currency conversion
0
Comment
Question by:Graeme
  • 3
  • 2
6 Comments
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 41717087
what do you mean by
I Don't want the count, I just want the output.

?
can you elaborate more?
0
 

Author Comment

by:Graeme
ID: 41717181
Hi Ryan, sorry the mobile app isnt as good as the PC

So the Query I currently have is:

Select * from tickets where event_ID=20

Open in new window


its output is:
USD
USD
SGD
AUD
AUD
SGD
SGD
AUD
AUD
AUD

I know if I do a count of these, its
2x USD
3x SGD
5x AUD

but I do not want the count (the numeric number)

I want the output (3 different types)
USD
SGD
AUD

hope this makes more sense
0
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 41717227
i'm not too sure if I understand you, but think you can use a Group By clause here?

like:
Select currencyfield
from tickets
where event_ID=20
group by currencyfield
order by by currencyfield

Open in new window

see if this is what you want?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:Graeme
ID: 41717231
Oh that might be the way, let me try it out, will get back to you soon

Cheers!
0
 

Author Closing Comment

by:Graeme
ID: 41722147
Perfect mate! cheers!
0
 
LVL 6

Expert Comment

by:worthyking1
ID: 41724931
A much simpler way is to use the DISTINCT method, as follows:

Select DISTINCT CurrencyType from tickets where event_ID=20

Open in new window


* Obviously replace "CurrencyType" above with your actual column name. You can also add ORDER BY if needed to sort the results.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question