Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nikhilgarg
Specialist II
Specialist II

How to write sql query in EditScript ??

Hey,

I have 3 columns say:  Item1 , Item2 , Item3. Now i have to count their numbers by writing SqlQueries.

In expression i have used Count(Item1Id), COunt(Item2Id) , Count(Item3Id).

In Script window how can i write the same in Sql query form?? Because if i write:

SQL Select count(Item1ID) from abc ; but what do i write in LOAD statement above it??

tHanks

28 Replies
alex_millan
Creator III
Creator III

LOAD 'Item1' As Item, NCount;

SQL SQL Select count(Item1ID) As NCount from abc;

giakoum
Partner - Master II
Partner - Master II

one SQL too many

nikhilgarg
Specialist II
Specialist II
Author

Hey Thankx but i have to select all coulmns and have to count as well.

Can i write:

SQL Select * , Cout(Item1) As NCount from abc;

alex_millan
Creator III
Creator III

LOAD *; SQL SELECT...

😉

alex_millan
Creator III
Creator III

LOL, You know Ioannis, as always... two better than one! XD    (Just joking!)

giakoum
Partner - Master II
Partner - Master II

will not work unless you specify a group by clause as well

Not applicable

I do not believe you can as Count is a Aggragation function:

However you can do the following:

Temp:

Select

        Item1 ,

       Item1id,

       Item2 ,

       Item2id

From abc;

Count:

Load

          Item1 ,

          Count(Item1id)

Resident Temp

Group by Item1;

Regards

RL

anbu1984
Master III
Master III

Which database are you using?

SQL Select * , Count(Item1) Over() As NCount from abc;


Or


SQL Select * , (Select Count(Item1) From abc) As NCount from abc;

nikhilgarg
Specialist II
Specialist II
Author

Hey,

It is giving me error